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

Learn more

AutoIt GUICtrlCreateButton Function

Reference on the GUICtrlCreateButton of AutoIt - how to place buttons in GUIs.

Edited: 2015-01-15 22:07

The AutoIt GUICtrlCreateButton Function is used to create buttons in GUI windows.

Parameters

TextButton text
pixelsLeft side of control - computed according to GUICoordMode if -1.
pixelsTop of control - computed according to GUICoordMode if -1.
pixels [optional]The width of the control.
pixels [optional]The height of the control.
Style [optional]Controls the style of the window.
ExStyle [optional]Controls the extended style of the window.

AutoIt GUICtrlCreateButton Example

#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 1 was pressed')
     Case $msg = $Button2
       MsgBox(0, 'Button 2', 'Button 2 was pressed')
    EndSelect
  WEnd
EndFunc