;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; AutoIt Version: 3.3.0.0 ;; ;; ;; ;; Template AutoIt script. ;; ;; ;; ;; AUTHOR: TheSaint ;; ;; ;; ;; SCRIPT FUNCTION: GUI creation program based on Cyberslug's AutoBuilder/GuiBuilder ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; FUNCTIONS ; RepaintMainWindow() #include #include #include #include #include #include #include _Singleton("gui-builder-thesaint") Global $Pic_back Global $about, $ans, $assigns, $backbmp, $blankbmp, $code, $col, $destfile, $exit, $file, $grid Global $gridsnap, $guititle, $h, $i, $iconset, $includes, $info, $load, $Main, $mygui, $notyet Global $paste, $pastepos, $properties, $row, $sampleavi, $samplebmp, $save, $settings, $show Global $showgrid, $showhidden, $snap, $state, $tips, $Toolbar, $type[22], $vals, $w, $winsize $backbmp = @ScriptDir & "\background.bmp" $blankbmp = @ScriptDir & "\blank.bmp" $iconset = @ScriptDir & "\IconSet.icl" $sampleavi = @ScriptDir & "\sampleAVI.avi" $samplebmp = @ScriptDir & "\SampleImage.bmp" ; GUI for "Main Drawing form" $Main = GuiCreate("GUIBuilder - Form", 400, 410, 185, @DesktopHeight / 2 - 175, $WS_POPUP + $WS_CAPTION + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_THICKFRAME) $Pic_back = 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($Pic_back, $GUI_DISABLE) ;disable background so that user can click buttons GuiSetState(@SW_SHOW) $Toolbar = GuiCreate("Choose Control Type", 168, 450, 10, @DesktopHeight / 2 - 175, $WS_POPUP + $WS_CAPTION, -1, $Main) ;GUISetFont(6, 400, 0, "Small Fonts", $Toolbar) ; $settings = GUICtrlCreateMenu("Settings") ;GUICtrlSetFont($settings, 6, 400, 0, "Small Fonts") $showgrid = GUICtrlCreateMenuItem("Show grid", $settings) GUICtrlSetState($showgrid, $GUI_CHECKED) $gridsnap = GUICtrlCreateMenuItem("Snap to grid", $settings) GUICtrlSetState($gridsnap, $GUI_CHECKED) $pastepos = GUICtrlCreateMenuItem("Paste at mouse position", $settings) GUICtrlSetState($pastepos, $GUI_CHECKED) $showhidden = GUICtrlCreateMenuItem("Show disabled controls", $settings) GUICtrlSetState($showhidden, $GUI_UNCHECKED) $properties = GUICtrlCreateMenuitem("Properties", -1) $exit = GUICtrlCreateMenuitem("Exit", -1) $load = GUICtrlCreateMenuitem("LoadTemplate", -1) $info = GUICtrlCreateMenuitem("Info", -1) $vals = GUICtrlCreateMenuitem("Vals", -1) $save = GUICtrlCreateMenuitem("SaveTemplate", -1) $about = GUICtrlCreateMenuitem("About", -1) ; $tips = StringSplit("Cursor|Tab|Group|Button|Checkbox|Radio|Edit|Input|Label|UpDown|List|Combo|Date|Treeview|Progress|Avi|Icon|Pic|Menu|ContextMenu|Slider", "|") $notyet = ",2,10,16,19,20," ;cursor is index 1 For $row = 0 to 6 For $col = 0 to 2 $i = (3 * $row) + $col + 1 ;convert row,col to linear index $type[$i] = GUICtrlCreateRadio("foo", $col * 56, $row * 56, 56, 56, $BS_PUSHLIKE + $BS_ICON) GUICtrlSetTip($type[$i], $tips[$i]) GUICtrlSetImage($type[$i], $iconset, -($i + 1), 1) ;GUICtrlSetImage($type[$i], $iconset, $i, 1) If StringInStr($notyet, "," & $i & ",") Then GuiCtrlSetState($type[$i], $GUI_DISABLE) Next Next GuiCtrlSetState($type[1], $GUI_CHECKED) ;initial selection $mygui = "MyGUI.au3" $grid = 1 $paste = 1 $show = 4 $snap = 1 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 Or $msg[0] = $exit ; Exit or Quit program $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 Case $msg[0] = $vals ; Current Code Values Local $numctrls = 0 MsgBox(262208, "Current Code Values", "Total Of Controls = " & $numctrls & @LF _ & "Control Number = 0" & @LF _ & "Control Type = none" & @LF & "Caption = none", 0, $Toolbar) Case $msg[0] = $showhidden ; Show disabled controls If $show = 1 Then $show = 4 Else $show = 1 EndIf GUICtrlSetState($showhidden, $show) For $row = 0 to 6 For $col = 0 to 2 $i = (3 * $row) + $col + 1 ;convert row,col to linear index If StringInStr($notyet, "," & $i & ",") > 0 Then If $show = 1 Then $state = $GUI_ENABLE Else $state = $GUI_DISABLE EndIf GuiCtrlSetState($type[$i], $state) EndIf Next Next WinActivate($main) Case $msg[0] = $showgrid ; Show grid GUISwitch($Main) If $grid = 1 Then $grid = 4 GUICtrlSetImage($Pic_back, $blankbmp) Else $grid = 1 GUICtrlSetImage($Pic_back, $backbmp) EndIf GUISwitch($Toolbar) GUICtrlSetState($showgrid, $grid) ;WinActivate($Main) ;RepaintMainWindow() _WinAPI_RedrawWindow($Main) Case $msg[0] = $pastepos ; Paste at mouse position If $paste = 1 Then $paste = 4 Else $paste = 1 EndIf GUICtrlSetState($pastepos, $paste) WinActivate($main) Case $msg[0] = $info ; Program Information MsgBox(262208, "Program Information", "When you exit GUIBuilder, you will be prompted" & @LF & _ "to save what you may have created." & @LF & @LF & _ "If you select 'Yes' then up to three options will" & @LF & _ "become available." & @LF & _ "1) Pasted into Scite if open, or use a dialog to" & @LF & _ "2) Save to a script (.au3) file, or if cancelled" & @LF & _ "3) Copied to the clipboard automatically!" & @LF & @LF & _ "Current title = " & $mygui, 0, $Toolbar) Case $msg[0] = $gridsnap ; Snap to grid If $snap = 1 Then $snap = 4 Else $snap = 1 EndIf GUICtrlSetState($gridsnap, $snap) WinActivate($main) Case $msg[0] = $about ; About GUIBuilder $ans = MsgBox(262465, "About GUIBuilder", "Prototype 1.0 - GUIBuilder is developed by TheSaint, and is based" & @LF _ & "on AutoBuilder/GuiBuilder created by CyberSlug, which had been" & @LF _ & "modified at various times by others, including Roy and TheSaint." & @LF & @LF _ & "OK = Go to the AutoIt Forum page for details." & @LF & @LF _ & "© January 2016 by TheSaint!", 0, $Toolbar) If $ans = 1 Then ShellExecute("https://www.autoitscript.com/forum/topic/167013-autoit-gui-creators-designers/") 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 Func RepaintMainWindow() ; Original method ; The SplashText forces the Helper window to repaint its controls ;Local $p = WinGetPos($Main) ;SplashTextOn("", "", $p[2], $p[3], $p[0], $p[1], 1) ;SplashOff() ; Another method ;WinSetState($Main, "", @SW_HIDE) ;WinSetState($Main, "", @SW_SHOW) EndFunc