Provides an interface for modifying GUI controls and retrieving information about them. Gui.Add, Gui.Control, GuiCtrlFromHwnd and Gui._NewEnum returns 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
Retrieves or sets the name of the control.
RetrievedName := GuiCtrl.Name
GuiCtrl.Name := NewName
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.
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. ErrorLevel is set to 0 if at least one of the specified changes was successfully applied. Otherwise, it is set to 1 to indicate that none of the changes could be applied. Even if a change is successfully applied, the control might choose to ignore it.
Moves and/or resizes the control, optionally with drawing it again.
GuiCtrl.Move(Pos , Draw := false)
One or more of the following option letters (specify each number as decimal, not hexadecimal):
Xn: Specify for n the new x-coordinate relative to the GUI window's client area, which is the area not including title bar, menu bar, and borders.
Yn: Specify for n the new y-coordinate relative to the GUI window's client area (see above).
Wn: Specify for n the new width of the control.
Hn: Specify for n the new height of the control.
MyEdit.Move("x10 y20 w200 h100", true) MyEdit.Move("x%VarX+10% y%VarY+5% w%VarW*2% h%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.
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:
Gui.Opt("+LastFound") ; Avoids the need to specify WinTitle below. PostMessage(0x185, 1, -1, ListBox.ClassNN) ; Select all items. 0x185 is LB_SETSEL. PostMessage(0x185, 0, -1, ListBox.ClassNN) ; Deselect all items. ListBox.Choose(0) ; Deselect all items.
Causes subsequently added controls to be belong to the specified tab of a Tab control.
GuiCtrl.UseTab(Value, ExactMatch := false)
Appends the specified entries at the current list of a ListBox, DropDownList, ComboBox, or Tab control.
"Red|Green|Blue") or an array of entries (e.g.
["Red", "Green", "Blue"]) to be appended at the end of the control's list. To replace (overwrite) the list instead, use GuiCtrl.Delete beforehand. When using pipes, one of the entries can be pre-selected by including two pipes after it (e.g.
"Red|Green||Blue"), otherwise use GuiCtrl.Choose. The separator between text fields may be changed to something other than pipe. For example,
Gui.Opt("+Delimiter`n")would change it to linefeed and
Gui.Opt("+DelimiterTab")would change it to tab (`t).
Deletes the specified entry or all entries of a ListBox, DropDownList, ComboBox, or Tab control.
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.
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 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
*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 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 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 commands 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 control; otherwise blank. Examples:
NewValue can be a set of modifiers with a key name, or blank to clear the control. Examples:
+Home. The only modifiers supported are ^ (Control), ! (Alt), and + (Shift). See the key list for available key names.
RetrievedValue is 1 if the 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.
RetrievedValue is a date-time stamp in YYYYMMDDHH24MISS format.
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.
RetrievedValue is the control's current position.
NewValue is the new position of the control, for example
MySlider.Value := 10. To adjust the value by a relative amount, use the operators
-- instead of
:=. If the new position would be outside the range of the control, the control is generally set to the nearest valid value.
RetrievedValue is the position of the currently selected item/tab or zero if none is selected. 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.
Retrieves or sets the text/caption of the control.
RetrievedText := GuiCtrl.Text
GuiCtrl.Text := NewText
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
`n, use GuiCtrl.Value.
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.
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.
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.
PosSizeObj := GuiCtrl.Pos
The position is relative to the GUI window's client area, which is the area not including title bar, menu bar, and borders. The information is stored in an object. For example:
value := MyEdit.Pos MsgBox The X coordinate is %value.x%. The Y coordinate is %value.y%. The width is %value.w%. The height is %value.h%.