Search code examples
autoit

ControlCommand in AutoIt v3


I am trying to use ControlCommands with a .NET application (hence, these should all be standard Microsoft controls), but most of the ones that are of interest don't seem to do anything.

I am currently looking at a combobox (the drop down box). I used the "showdropdown" command to have it drop down, and it worked successfully.

I then tried to use "SelectString", but it didn't go to the string that I specified. How does the "SelectString" ControlCommand option work?

I have also tried "SetCurrentSelection".

This is the statement I used:

ControlCommand($windowName, "", "[Name:myComboBox]", "SelectString", "a")

I have also tried searching for it first with:

ControlCommand($windowName, "", "[Name:myComboBox]", "FindString", "a")

but it didn't find it either. Strange, the single character "a" is there.

If it helps, this is the control class: WindowsForms10.COMBOBOX


Solution

  • _GUICtrlComboBox_xxx functions also work on external controls. For example, _GUICtrlComboBox_FindString, _GUICtrlComboBox_SelectString, _GUICtrlComboBox_SetCurSel. Try those instead.

    Call ControlGetHandle first, then use this handle to call the functions above.

    Remember to include the GuiComboBox library, otherwise you will get an error message "Error: Unknown function name":

    #include <GuiComboBox.au3>