AutoIT GUICreate
How to use the GUICreate function to create GUIs in AutoIt.
2709 views

Edited: 2017-02-10 21:31
The AutoIT GUICreate function is used when creating GUIs. The behavior of the created GUI window can be controlled trough the style and exStyle parameters.
There are multiple ways to create GUIs in AutoIt, some of which are included here. You may also want to check the tutorials for a more in-dept explanation.
Parameters
| Title | The title of the GUI Window |
| Width [optional] | The Width of the Window |
| Height [optional] | The Height of the Window |
| Left [optional] | Default (-1) is centered. If defined, Top must also be defined. |
| Top [optional] | Default (-1) is centered. If defined, Left must also be defined. |
| Style [optional] | Controls the style of the window. |
| ExStyle [optional] | Controls the extended style of the window. |
| Parent [optional] | The handle of a previously created window. If given, the new window will then become a child of the previously created one. |
Example
The below GUI includes two buttons, you can easily extend it with more buttons. What happens when a button is pressed is controlled with the select statement.
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
MainGUI()
Func MainGUI()
Local $Button1, $Button2, $msg
GUICreate("My GUI Window Title")
Opt("GUICoordMode", 2)
$Button1 = GUICtrlCreateButton("Button 1", 10, 30, 100)
$Button2 = GUICtrlCreateButton("Button 2", 0, -1)
GUISetState()
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button1
MsgBox(0, 'Button 1', 'Button 2 was pressed')
Case $msg = $Button2
MsgBox(0, 'Button 2', 'Button 2 was pressed')
EndSelect
WEnd
EndFunc
Links
- GUICreate - autoitscript.com

Tell us what you think: