Method ControlCommand

AutoIt X

Method Reference


ControlCommand

Sends a command to a control

ControlCommand "title", "text", "controlID", "command", "option"

Parameters

title The title of the window to access.
text The text of the window to access.
controlID The control to interact with. See Controls.
command The command to send to the control.
option Additional parameter required by some commands; use "" if parameter is not required.

Return Value

Depends on command as table below shows. In case of an error (such as an invalid command or window/control), oAutoIt.error=1.

Command, Option Return Value
"IsVisible", "" Returns 1 if Control is visible, 0 otherwise
"IsEnabled", "" Returns 1 if Control is enabled, 0 otherwise
"ShowDropDown", "" Drops a ComboBox
"HideDropDown", "" UNdrops a ComboBox
"AddString", 'string' Adds a string to the end in a ListBox or ComboBox
"DelString", occurrence Deletes a string according to occurrence in a ListBox or ComboBox
"FindString", 'string' Returns occurrence ref of the exact string in a ListBox or ComboBox
"SetCurrentSelection", occurrence Sets selection to occurrence ref in a ListBox or ComboBox
"SelectString", 'string' Sets selection according to string in a ListBox or ComboBox
"IsChecked", "" Returns 1 if Button is checked, 0 otherwise
"Check", "" Checks radio or check Button
"UnCheck", "" Unchecks radio or check Button
"GetCurrentLine", "" Returns the line # where the caret is in an Edit
"GetCurrentCol", "" Returns the column # where the caret is in an Edit
"GetCurrentSelection", "" Returns name of the currently selected item in a ListBox or ComboBox
"GetLineCount", "" Returns # of lines in an Edit
"GetLine", line# Returns text at line # passed of an Edit
"GetSelected", "" Returns selected text of an Edit
"EditPaste", 'string' Pastes the 'string' at the Edit's caret position
"CurrentTab", "" Returns the current Tab shown of a SysTabControl32
"TabRight", "" Moves to the next tab to the right of a SysTabControl32
"TabLeft", "" Moves to the next tab to the left of a SysTabControl32

Remarks

Certain commands that work on normal Combo and ListBoxes do not work on "ComboLBox" controls.
When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2". Use AU3_Spy.exe to obtain a control's number.

When using text instead of ClassName# in "Control" commands, be sure to use the entire text of the control. Partial text will fail.

Related

ControlClick, ControlDisable, ControlEnable, ControlFocus, ControlGetPosX, ControlGetPosY, ControlGetText, ControlHide, ControlMove, ControlSetText, ControlShow, StatusbarGetText, WinGetClassList, WinMenuSelectItem

Example


Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlCommand "Untitled - Notepad", "", "Edit1", "GetLineCount", ""