Control Functions

Functions to retrieve information about a control, or make a variety of changes to a control. Click on a function name for details.

Function Description
ControlAddItem Adds the specified string as a new entry at the bottom of a ListBox or ComboBox.
ControlChooseIndex Sets the selection in a ListBox, ComboBox or Tab control to be the specified entry or tab number.
ControlChooseString Sets the selection in a ListBox or ComboBox to be the first entry whose leading part matches the specified string.
ControlClick Sends a mouse button or mouse wheel event to a control.
ControlDeleteItem Deletes the specified entry number from a ListBox or ComboBox.
ControlFindItem Returns the entry number of a ListBox or ComboBox that is a complete match for the specified string.
ControlFocus Sets input focus to a given control on a window.
ControlGetChecked Returns a non-zero value if the checkbox or radio button is checked.
ControlGetChoice Returns the name of the currently selected entry in a ListBox or ComboBox.
ControlGetClassNN Returns the ClassNN (class name and sequence number) of the specified control.
ControlGetEnabled Returns a non-zero value if the specified control is enabled.
ControlGetFocus Retrieves which control of the target window has keyboard focus, if any.
ControlGetHwnd Returns the unique ID number of the specified control.
ControlGetIndex Returns the index of the currently selected entry or tab in a ListBox, ComboBox or Tab control.
ControlGetItems Returns an array of items/rows from a ListBox, ComboBox, or DropDownList.
ControlGetPos Retrieves the position and size of a control.
ControlGetStyle
ControlGetExStyle
Returns an integer representing the style or extended style of the specified control.
ControlGetText Retrieves text from a control.
ControlGetVisible Returns a non-zero value if the specified control is visible.
ControlHide Hides the specified control.
ControlHideDropDown Hides the drop-down list of a ComboBox control.
ControlMove Moves or resizes a control.
ControlSend
ControlSendText
Sends simulated keystrokes or text to a window or control.
ControlSetChecked Turns on (checks) or turns off (unchecks) a checkbox or radio button.
ControlSetEnabled Enables or disables the specified control.
ControlSetStyle
ControlSetExStyle
Changes the style or extended style of the specified control, respectively.
ControlSetText Changes the text of a control.
ControlShow Shows the specified control if it was previously hidden.
ControlShowDropDown Shows the drop-down list of a ComboBox control.
EditGetCurrentCol Returns the column number in an Edit control where the caret (text insertion point) resides.
EditGetCurrentLine Returns the line number in an Edit control where the caret (text insert point) resides.
EditGetLine Returns the text of the specified line in an Edit control.
EditGetLineCount Returns the number of lines in an Edit control.
EditGetSelectedText Returns the selected text in an Edit control.
EditPaste Pastes the specified string at the caret (text insertion point) in an Edit control.
ListViewGetContent Returns a list of items/rows from a ListView.

The Control Parameter

Functions which operate on individual controls have a parameter named Control which supports a few different ways to identify the control. The Control parameter can be one of the following:

ClassNN (String): The ClassNN (classname and instance number) of the control, which can be determined via Window Spy. For example "Edit1" is the first control with classname "Edit".

Text (String): The control's text. The matching behavior is determined by SetTitleMatchMode.

HWND (Integer): The control's HWND, which is typically retrieved via ControlGetHwnd, MouseGetPos, or DllCall. This also works on hidden controls even when DetectHiddenWindows is Off. Any subsequent window parameters are ignored.

Object: An object of any type with a Hwnd property, such as a GuiControl. A PropertyError is thrown if the object has no Hwnd property, or TypeError if it does not return a pure integer. Any subsequent window parameters are ignored.

Omitted: A few functions are able to operate on either a control or a top-level window. Omitting the Control parameter causes the function to use the target window (specified by WinTitle) instead of one of its controls. For example, ControlSend can send keyboard messages directly to the window.

Error Handling

Typically one of the following errors may be thrown:

Remarks

To improve reliability, a delay is done automatically after each use of a Control function that changes a control (except for ControlSetStyle and ControlSetExStyle). That delay can be changed via SetControlDelay or by assigning a value to A_ControlDelay. For details, see SetControlDelay remarks.

To discover the ClassNN or HWND of the control that the mouse is currently hovering over, use MouseGetPos.

To retrieve a list of all controls in a window, use WinGetControls or WinGetControlsHwnd.

Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.

SetControlDelay, Win functions, GuiControl object (for controls created by the script)