GuiControl Object

Provides an interface for modifying GUI controls and retrieving information about them. Gui.Add, Gui.__Item and GuiCtrlFromHwnd return an object of this type.




Retrieves the type of the control.

Type := GuiCtrl.Type

For a full list of control types, see GUI control types.


Retrieves the window handle (HWND) of the control.

Hwnd := GuiCtrl.Hwnd

A control's HWND is often used with PostMessage, SendMessage, and DllCall.


Retrieves or sets the name of the control.

RetrievedName := GuiCtrl.Name
GuiCtrl.Name := NewName

The control's name can be used with Gui.__Item to retrieve the GuiControl object. For most input-capable controls, the name is also used by Gui.Submit.


Retrieves the ClassNN of the control.

ClassNN := GuiCtrl.ClassNN


Retrieves the Gui object of the control's parent GUI window.

GuiObj := GuiCtrl.Gui


Adds or removes various options and styles of the control.


Type: String

Either control-specific or general options and styles.

In the following example, the control is disabled and its background is restored to the system default:

MyEdit.Opt("+Disabled -Background")

In the next example, the OK button is made the new default button:


Although styles and extended styles are also recognized, some of them cannot be applied or removed after a control has been created. Even if a change is successfully applied, the control might choose to ignore it.


Moves and/or resizes the control.

GuiCtrl.Move(X, Y, Width, Height)
X, Y

Type: Integer

The new position, relative to the GUI window's client area, which is the area not including title bar, menu bar, and borders.

Width, Height

Type: Integer

The new size.

Unlike ControlMove, this method applies DPI scaling to the coordinates (unless the -DPIScale option was used).


MyEdit.Move(10, 20, 200, 100)
MyEdit.Move(VarX+10, VarY+5, VarW*2, VarH*1.5)


Sets keyboard focus to the control.


Note: To be effective, the window generally must not be minimized or hidden.


Sets the selection in a ListBox, DropDownList, ComboBox, or Tab control to be the specified value.


Type: Integer or String

This parameter should be 1 for the first entry, 2 for the second, etc.

If Value is a string (even a numeric string), the entry whose leading part matches Value will be selected. The search is not case sensitive. For example, if the control contains the item "UNIX Text", specifying the word unix (lowercase) would be enough to select it. For a multi-select ListBox, all matching items are selected.

If Value is zero or empty, the current selection is removed.

To select or deselect all items in a multi-select ListBox, follow this example:

PostMessage 0x185, 1, -1, ListBox  ; Select all items. 0x185 is LB_SETSEL.
PostMessage 0x185, 0, -1, ListBox  ; Deselect all items.
ListBox.Choose(0)  ; Deselect all items.

Unlike ControlChooseIndex, this method does not raise a Change or DoubleClick event.


Causes subsequently added controls to be belong to the specified tab of a Tab control.

GuiCtrl.UseTab(Value, ExactMatch := false)

Type: Integer or String

This parameter should be 1 for the first tab, 2 for the second, etc. If Value is not an integer, the tab whose leading part matches Value will be used. The search is not case sensitive. For example, if a the control contains the tab "UNIX Text", specifying the word unix (lowercase) would be enough to use it. If Value is zero, a blank string or omitted, subsequently controls are added outside the Tab control.


Type: Integer (boolean)

If this parameter is true, Value has to be an exact match, but not case sensitive.


Appends list items to a ListBox, DropDownList or ComboBox, or tabs to a Tab control.


Type: Array

An array of strings (e.g. ["Red","Green","Blue"]) to be inserted at the end of the control's list. To replace (overwrite) the list instead, use GuiCtrl.Delete beforehand.

Use GuiCtrl.Choose to select an item.

Related: ListView.Add, TreeView.Add


Deletes the specified entry or all entries of a ListBox, DropDownList, ComboBox, or Tab control.


Type: Integer

This parameter should be 1 for the first entry, 2 for the second, etc. If omitted, all entries are deleted.

For tab controls, you should note that a tab's sub-controls stay associated with their original tab number; that is, they are never associated with their tab's actual display-name. For this reason, renaming or removing a tab will not change the tab number to which the sub-controls belong. For example, if there are three tabs ["Red","Green","Blue"] and the second tab is removed by means of MyTab.Delete(2), the sub-controls originally associated with Green will now be associated with Blue. Because of this behavior, only tabs at the end should generally be removed. Tabs that are removed in this way can be added back later, at which time they will reclaim their original set of controls.

Related: ListView.Delete, TreeView.Delete


Retrieves or sets the contents of a control.

RetrievedValue := GuiCtrl.Value
GuiCtrl.Value := NewValue

Note: If the control is not value-capable, RetrievedValue will be blank and assigning NewValue will raise an error. Invalid values throw an exception.

Following control types are value-capable:


RetrievedValue is the picture's file name as it was originally specified when the Picture control was created. This name does not change even if a new picture file name is specified.

NewValue is the filename (or handle) of the new image to load (see Picture for supported file types). Zero or more of the following options may be specified immediately in front of the filename: *wN (width N), *hN (height N), and *IconN (icon group number N in a DLL or EXE file). In the following example, the default icon from the second icon group is loaded with a width of 100 and an automatic height via "keep aspect ratio": MyPic.Value := "*icon2 *w100 *h-1 C:\My Application.exe". Specify *w0 *h0 to use the image's actual width and height. If *w and *h are omitted, the image will be scaled to fit the current size of the control. When loading from a multi-icon .ICO file, specifying a width and height also determines which icon to load. Note: Use only one space or tab between the final option and the filename itself; any other spaces and tabs are treated as part of the filename.


RetrievedValue is the text/caption of the Text control.

NewValue is the control's new text. Since the control will not expand automatically, use GuiCtrl.Move("w300") if the control needs to be widened.


RetrievedValue is the current content of the Edit control. For multi-line controls, any line breaks in the text will be represented as plain linefeeds (`n) rather than the traditional CR+LF (`r`n) used by non-GUI functions such as ControlGetText and ControlSetText.

NewValue is the new content. For multi-line controls, Any linefeeds (`n) in NewValue that lack a preceding carriage return (`r) are automatically translated to CR+LF (`r`n) to make them display properly. However, this is usually not a concern because when using Gui.Submit or when retrieving this value this translation will be reversed automatically by replacing CR+LF with LF (`n).

To retrieve or set the text without translating `n to or from `r`n, use GuiCtrl.Text.


RetrievedValue is the modifiers and key name if there is a hotkey in the Hotkey control; otherwise blank. Examples: ^!C, ^Home, +^NumpadHome.

NewValue can be a set of modifiers with a key name, or blank to clear the control. Examples: ^!c, ^Numpad1, +Home. The only modifiers supported are ^ (Control), ! (Alt), and + (Shift). See the key list for available key names.

Checkbox / Radio

RetrievedValue is 1 if the Checkbox or Radio control is checked, 0 if it is unchecked, or -1 if it has a gray checkmark.

NewValue can be 0 to uncheck the button, 1 to check it, or -1 to give it a gray checkmark. For Radio buttons, if one is being checked (turned on) and it is a member of a multi-radio group, the other radio buttons in its group will be automatically unchecked.

To get or set control's text/caption instead, use GuiCtrl.Text.

DateTime / MonthCal

RetrievedValue is a date-time stamp in YYYYMMDDHH24MISS format currently selected in the DateTime or MonthCal control.

NewValue is a date-time stamp in YYYYMMDDHH24MISS format. Specify A_Now to use the current date and time (today). For DateTime controls, NewValue may be an empty string to cause the control to have no date/time selected (if it was created with that ability). For MonthCal controls, a range may be specified if the control is multi-select.

UpDown / Slider / Progress

RetrievedValue is the current position of the UpDown, Slider or Progress control.

NewValue is the new position of the control, for example MySlider.Value := 10. To adjust the value by a relative amount, use the operators +=, -=, ++ or -- instead of :=. If the new position would be outside the range of the control, the control is generally set to the nearest valid value.

Tab / DropDownList / ComboBox / ListBox

RetrievedValue is the position of the currently selected item/tab in the Tab, DropDownList, ComboBox or ListBox control. If none is selected, zero is returned. If text is entered into a ComboBox, the first item with matching text is used. If there is no matching item, the result is zero even if there is text in the control. For a multi-select ListBox, the result is an array of numbers (which is empty if no items are selected).

NewValue is the position of a single item/tab to select, or zero to clear the current selection (this is valid even for Tab controls). To select multiple items, call GuiCtrl.Choose repeatedly.

To get or set the selected item given its text instead of its position, use GuiCtrl.Text.


RetrievedValue is the ActiveX object of the ActiveX control. For example, if the control was created with the text Shell.Explorer, this is a WebBrowser object. The same wrapper object is returned each time.


Retrieves or sets the text/caption of the control.

RetrievedText := GuiCtrl.Text
GuiCtrl.Text := NewText

Note: If the control has no visible caption text and no (single) text value, this property corresponds to the control's hidden caption text (like ControlGetText/ControlSetText).

Caption/display text: The Text property retrieves or sets the caption/display text of the following control types: Button, Checkbox, Edit, GroupBox, Link, Radio, Text. Since the control will not expand automatically, use GuiCtrl.Move("w300") or similar if the control needs to be widened.

DateTime: The Text property retrieves the formatted text displayed by the control. Assigning a formatted date/time string to the control is not supported. To change the date/time being displayed, assign GuiCtrl.Value a date-time stamp in YYYYMMDDHH24MISS format.

Edit: As with other controls, the text is retrieved or set as-is; no end-of-line translation is performed. To retrieve or set the text of a multi-line Edit control while also translating between `r`n and `n, use GuiCtrl.Value.

StatusBar: The Text property retrieves or sets the text of the first part only (use SB.SetText for greater flexibility).

List item text: The Text property retrieves or sets the currently selected item/tab for the following control types: Tab, DropDownList, ComboBox, ListBox.

NewText should be the full text (case insensitive) of the item/tab to select.

For a ComboBox, if there is no selected item, the text in the control's edit field is retrieved instead. For other controls, RetrievedText is empty/blank. Similarly, if NewText is empty/blank, the current item/tab will be deselected.

For a multi-select ListBox, RetrievedText is an array. NewText cannot be an array, but if multiple items match, they are all selected. To select multiple items with different text, call GuiCtrl.Choose repeatedly.

To select an item by its position number instead of its text, use GuiCtrl.Value.


Redraws the region of the GUI window occupied by the control.


Although this may cause an unwanted flickering effect when called repeatedly and rapidly, it solves display artifacts for certain control types such as GroupBoxes.


Sets the font typeface, size, style, and/or color for the control.

Note: Omit both parameters to set the font to the GUI's current font, as set by Gui.SetFont. Otherwise, any font attributes which are not specified will be copied from the control's previous font. Text color is changed only if specified in Options.

GuiCtrl.SetFont(Options, FontName)

For details about both parameters, see Gui.SetFont.


Retrieves the current interaction state of the control, or enables or disables (grays out) it.

RetrievedState := GuiCtrl.Enabled
GuiCtrl.Enabled := NewState

For Tab controls, this will also enable or disable all of the tab's sub-controls. However, any sub-control explicitly disabled via GuiCtrl.Enabled := false will remember that setting and thus remain disabled even after its Tab control is re-enabled.


Retrieves the current visibility state of the control, or shows or hides it.

RetrievedState := GuiCtrl.Visible
GuiCtrl.Visible := NewState

For Tab controls, this will also show or hide all of the tab's sub-controls. If you additionally want to prevent a control's shortcut key (underlined letter) from working, disable the control via GuiCtrl.Enabled := false.


Retrieves the current focus state of the control.

RetrievedState := GuiCtrl.Focused

Note: To be effective, the window generally must not be minimized or hidden.


Retrieves the position and size of the control.

GuiCtrl.GetPos(X, Y, Width, Height)

Each parameter should be a variable in which to store the respective coordinate. The position is relative to the GUI window's client area, which is the area not including title bar, menu bar, and borders.

Unlike ControlGetPos, this method applies DPI scaling to the returned coordinates (unless the -DPIScale option was used).


MyEdit.GetPos(x, y, w, h)
MsgBox "The X coordinate is " x ". The Y coordinate is " y ". The width is " w ". The height is " h "."