ControlGetItems

Returns an array of items/rows from a ListBox, ComboBox, or DropDownList.

Items := ControlGetItems(Control , WinTitle, WinText, ExcludeTitle, ExcludeText)

Parameters

Control

Type: String, Integer or Object

The control's ClassNN, text or HWND, or an object with a Hwnd property. For details, see The Control Parameter.

WinTitle

Type: String, Integer or Object

A window title or other criteria identifying the target window. See WinTitle.

WinText

Type: String

If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.

ExcludeTitle

Type: String

Windows whose titles include this value will not be considered.

ExcludeText

Type: String

Windows whose text include this value will not be considered.

Return Value

Type: Array

This function returns an array of items/rows.

Error Handling

An exception is thrown on failure. Failure occurs when: 1) the target window or control does not exist; 2) the target control is not of a recognized type; 3) a message could not be sent to the target control.

Remarks

Some applications store their item data privately, which prevents their text from being retrieved. In these cases, an exception will usually not be thrown, but all the retrieved fields will be empty.

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

Related

ListViewGetContent, WinGetList, Control functions

Examples

#1: Accesses the items one by one.

for item in ControlGetItems("ComboBox1", WinTitle)
    MsgBox "Item number " A_Index " is " item

#2: Accesses a specific item by index.

items := ControlGetItems("ListBox1", WinTitle)
MsgBox "The first item is " items[1]
MsgBox "The last item is " items[-1]