Makes a variety of changes to a control.
Control, SubCommand , Value, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
Can be either ClassNN (the classname and instance number of the control) or the control's text, both of which can be determined via Window Spy. When using text, the matching behavior is determined by SetTitleMatchMode. If this parameter is blank, the target window's topmost control will be used.
To operate upon a control's HWND (window handle), leave the Control parameter blank and specify ahk_id %ControlHwnd%
for the WinTitle parameter (this also works on hidden controls even when DetectHiddenWindows is Off). The HWND of a control is typically retrieved via ControlGet Hwnd, MouseGetPos, or DllCall().
For SubCommand, specify one of the following:
Turns on (checks) a radio button or checkbox.
Control, Check ,, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
To ensure correct functionality, this sub-command also sets the input focus to the control.
Turns off a radio button or checkbox.
Control, Uncheck ,, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
To ensure correct functionality, this sub-command also sets the input focus to the control.
Enables a control if it was previously disabled.
Control, Enable ,, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
Disables or "grays out" a control.
Control, Disable ,, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
Shows a control if it was previously hidden.
Control, Show ,, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
Hides a control.
Control, Hide ,, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
If you additionally want to prevent a control's shortcut key (underlined letter) from working, disable the control via the Disable sub-command.
Changes the style of a control.
Control, Style, N , Control, WinTitle, WinText, ExcludeTitle, ExcludeText
If the first character of N is a plus or minus sign, the style(s) in N are added or removed, respectively. If the first character is a caret (^), the style(s) in N are each toggled to the opposite state. If the first character is a digit, the control's style is overwritten completely; that is, it becomes N. ErrorLevel is set to 1 if the target window/control is not found or the style is not allowed to be applied.
Certain style changes require that the entire window be redrawn using WinSet Redraw. Also, the styles table lists some of the style numbers. For example:
Control, Style, ^0x800000, Edit1, WinTitle ; Set the WS_BORDER style to its opposite state.
Changes the extended style of a control.
Control, ExStyle, N , Control, WinTitle, WinText, ExcludeTitle, ExcludeText
See the Style sub-command above for details.
Shows the drop-down list of a ComboBox control.
Control, ShowDropDown ,, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
Hides the drop-down list of a ComboBox control.
Control, HideDropDown ,, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
Moves left by one or more tabs in a SysTabControl32.
Control, TabLeft , Count, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
Count is assumed to be 1 if omitted or blank. To instead select a tab directly by number, replace the number 5 below with one less than the tab number you wish to select. In other words, 0 selects the first tab, 1 selects the second, and so on:
SendMessage, 0x1330, 5,, SysTabControl321, WinTitle ; 0x1330 is TCM_SETCURFOCUS. Sleep 0 ; This line and the next are necessary only for certain tab controls. SendMessage, 0x130C, 5,, SysTabControl321, WinTitle ; 0x130C is TCM_SETCURSEL.
Moves right by one or more tabs in a SysTabControl32.
Control, TabRight , Count, Control, WinTitle, WinText, ExcludeTitle, ExcludeText
See the TabLeft sub-command above for details.
Adds String as a new entry at the bottom of a ListBox, ComboBox (and possibly other types).
Control, Add, String , Control, WinTitle, WinText, ExcludeTitle, ExcludeText
Deletes the Nth entry from a ListBox or ComboBox.
Control, Delete, N , Control, WinTitle, WinText, ExcludeTitle, ExcludeText
N should be 1 for the first entry, 2 for the second, etc.
Sets the selection in a ListBox or ComboBox to be the Nth entry.
Control, Choose, N , Control, WinTitle, WinText, ExcludeTitle, ExcludeText
N should be 1 for the first entry, 2 for the second, etc. To select or deselect all items in a multi-select listbox, follow this example:
PostMessage, 0x0185, 1, -1, ListBox1, WinTitle ; Select all listbox items. 0x0185 is LB_SETSEL.
Sets the selection (choice) in a ListBox or ComboBox to be the first entry whose leading part matches String.
Control, ChooseString, String , Control, WinTitle, WinText, ExcludeTitle, ExcludeText
The search is not case sensitive. For example, if a ListBox/ComboBox contains the item "UNIX Text", specifying the word unix (lowercase) would be enough to select it.
Pastes String at the caret/insert position in an Edit control.
Control, EditPaste, String , Control, WinTitle, WinText, ExcludeTitle, ExcludeText
This does not affect the contents of the clipboard.
[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.
ErrorLevel is set to 1 if there was a problem or 0 otherwise.
To improve reliability, a delay is done automatically after every use of this command (except for the sub-commands Style and ExStyle). That delay can be changed via SetControlDelay.
To discover the ClassNN or HWND of the control that the mouse is currently hovering over, use MouseGetPos.
Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.
SetControlDelay, ControlGet, GuiControl, ControlGetText, ControlSetText, ControlMove, ControlGetPos, ControlClick, ControlFocus, ControlSend, WinSet