AutoIt GUICtrlCreateButton Function
How to use the AutoIt GUICtrlCreateButton function to create buttons in GUIs.
2304 views

Edited: 2017-02-10 21:49
The AutoIt GUICtrlCreateButton Function is used to create buttons in GUI windows.
Parameters
| Text | Button text |
| pixels | Left side of control - computed according to GUICoordMode if -1. |
| pixels | Top 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. |
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

Tell us what you think: