By using this site you agree to the use of cookies.

Learn more

Share via:

AutoIT GUICreate

How to use the GUICreate function to create GUIs in AutoIt.

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.


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.


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)


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')


  1. GUICreate -