;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; AutoIt Version: 3.3.0.0 ;; ;; ;; ;; Template AutoIt script. ;; ;; ;; ;; AUTHOR: TheSaint ;; ;; ;; ;; SCRIPT FUNCTION: GUI creation program based on Cyberslug's AutoBuilder/GuiBuilder ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #include #include #include #include #include Global $ans, $assigns, $backbmp, $background, $code, $destfile, $file, $guititle, $h, $includes, $main, $mygui, $toolbar, $w, $winsize $backbmp = @ScriptDir & "\background.bmp" ; GUI for "Main Drawing form" $main = GuiCreate("GUIBuilder - Form", 400, 410, 170, @DesktopHeight / 2 - 175, $WS_POPUP + $WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_THICKFRAME) $background = GUICtrlCreatePic($backbmp, 0, 0, 1024, 768) ;used to show a grid (NOTE - This is a set size, that extends beyond the bounds of current GUI size) GUICtrlSetState($background, $GUI_DISABLE) ;disable background so that user can click buttons GuiSetState(@SW_SHOW) $toolbar = GuiCreate("Choose Control Type", 150, 410, 10, @DesktopHeight / 2 - 175, $WS_POPUP + $WS_CAPTION, -1, $main) GuiSetState(@SW_SHOW) GUISwitch($main) ;Rather important! WinActivate($main) ; Main message loop.... While 1 ; show dimensions of window on the titlebar... $winsize = WinGetClientsize($main) If "GUIBuilder - Form (" & $winsize[0] & " x " & $winsize[1] & ")" <> WinGetTitle($main) Then WinSetTitle($main, "", "GUIBuilder - Form (" & $winsize[0] & " x " & $winsize[1] & ")") EndIf ; $msg = GuiGetMsg(1) Select Case $msg[0] = $GUI_EVENT_CLOSE $ans = MsgBox(262179, "Quit?", "Do you want to Save a GUI?" & @LF & @LF & "WARNING - All detail will be lost if NO is clicked." _ & @LF & @LF & "YES = Save GUI code to FILE or CLIPBOARD." & @LF & @LF & "CANCEL = Return to GUI CREATION process.", 0, $main) If $ans = 6 Then ExitLoop ElseIf $ans = 7 Then Exit ElseIf $ans = 2 Then ContinueLoop EndIf EndSelect ; WEnd $winsize = WinGetClientSize($main) $w = $winsize[0] $h = $winsize[1] GuiDelete($toolbar) GuiDelete($main) $includes = "#include " & @CRLF & "#include " & @CRLF _ & "#include " & @CRLF & "#include " $code = "; Script generated by GUIBuilder 1.0 Prototype" & @CRLF & @CRLF & $includes & @CRLF & @CRLF If $guititle = "" Then $guititle = "GUI Title" $code = $code & '$MyGUI = GuiCreate("' & $guititle & '", ' & $w & ", " & $h & ", -1, -1, $WS_OVERLAPPED + $WS_CAPTION + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_MINIMIZEBOX)" $assigns = ";" & @CRLF & "; CONTROLS" & @CRLF & ";" & @CRLF & "; SETTINGS" $code = $code & @CRLF & $assigns & @CRLF & @CRLF & @CRLF $code = $code & "GuiSetState()" & @CRLF & "While 1" & @CRLF & @TAB & "$msg = GuiGetMsg()" & @CRLF & @TAB & "Select" & @CRLF & @TAB $code = $code & "Case $msg = $GUI_EVENT_CLOSE" & @CRLF & @TAB & @TAB & "GUIDelete($MyGUI)" & @CRLF & @TAB & @TAB & "ExitLoop" & @CRLF & @TAB $code = $code & "Case Else" & @CRLF & @TAB & @TAB & ";;;" & @CRLF & @TAB & "EndSelect" & @CRLF & "WEnd" & @CRLF & @CRLF & "Exit" If StringInStr($CmdLineRaw, "/StdOut") Then ConsoleWrite("#region --- GuiBuilder code Start ---" & @LF) ConsoleWrite(StringReplace($code, @CRLF, @LF)) ConsoleWrite(@lf & "#endregion --- GuiBuilder generated code End ---" & @LF) Else If $mygui = "" Then $mygui = "MyGUI.au3" $destfile = FileSaveDialog("Save the GUI code to file? (Cancel = Save to Clipboard)", @ScriptDir, "AutoIt Script (*.au3)", 2, $mygui) If @error = 1 Or $destfile = "" Then ClipPut($code) SplashTextOn("Done", @CRLF & @CRLF & "Script copied to clipboard!", 220, 100) Else If FileExists($destfile) Then $ans = MsgBox(262449, "Overwrite Query", _ "The script file you wish to save to already exists." & @LF & @LF & _ "OK = Overwrite and replace content with new code." & @LF & _ "CANCEL = Add new code to the end of existing content.", 0) SplashTextOn("Done", @CRLF & "Saving to file!", 200, 100) If $ans = 1 Then _FileCreate($destfile) Sleep(500) _FileWriteToLine($destfile, 1, $code) ElseIf $ans = 2 Then $file = FileOpen($destfile, 1) FileWrite($file, $code) FileClose($file) EndIf Else FileWrite($destfile, $code) SplashTextOn("Done", @CRLF & "Saved to file!", 200, 100) EndIf EndIf Sleep(1000) SplashOff() EndIf Exit