# Function Reference

GUICtrlCreateButton

Creates a Button control for the GUI.

GUICtrlCreateButton ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the button control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $WS_TABSTOP, $BS_NOTIFY
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....
A Button control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage to specify the picture to use.
To combine styles with the default style use BitOr($GUI_SS_DEFAULT_BUTTON, newstyle,...).
Default resizing is $GUI_DOCKSIZE

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>
GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered
Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100)
$Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1)
GUISetState () ; will display an dialog box with 2 button
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
Run('Notepad.exe') ; Will Run/Open Notepad
Case $msg = $Button_2
MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
EndSelect
Wend