By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

AutoIT GUICreate

Reference on the GUICreate function of AutoIT - includes useful examples and explanations.

Edited: 2014-12-31 03:26

The AutoIT GUICreate function is used when creating GUIs. How the windows behave can be controlled trough the style and exStyle parameters.


TitleThe 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.

AutoIT GUICreate Example

The below GUI includes two buttons, you can easily extend it with more buttons. What happens when a button is pressed, can be controlled with the select statement.

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)


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)


  ; Run the GUI until the dialog is closed
  While 1
    $msg = GUIGetMsg()
     Case $msg = $GUI_EVENT_CLOSE
     Case $msg = $Button1
       MsgBox(0, 'Button 1', 'Button 2 was pressed')
     Case $msg = $Button2
       MsgBox(0, 'Button 2', 'Button 2 was pressed')