Jump to content

Unable to select, find, showdropdown in specific combobox

Recommended Posts

Dear Community,

I am doing automation tasks using AutoIT since years and I am the opinion that it's a really impressive tool for such reason.

Last week I found a task that I am not able to fulfill.

I have got a form (of an 3rd party application) where I do want to select a defined entry and hit the "OK" Button afterwards. The combobox looks like this:



My first approach was the one I used some hundret times in the past ...


WinWait("Deckenprogramm wählen", "")
WinActivate("Deckenprogramm wählen", "")

$ComboBox = ControlGetHandle("Deckenprogramm wählen", "", "[CLASS:ComboBox; INSTANCE:1]")

$ID = _GUICtrlComboBox_SetCurSel($ComboBox, 1)

Unfortunately the form and the combobox do not react to this command.

Expanding the combobox or trying to get the count of entries fail as well.


I also tried to use "sendmessage" like shown below:


DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int", 0)


No luck as well.


Is there anything else I can try?


Each advise is very welcome!


Link to post
Share on other sites



This is how the expanded combobox looks like when I click on it.

Sending "ControlClick" opens the dropdown and I can use "Send" to send a down key but I am not able to confirm the selection with an "Enter" or "Space" or anything else ... moreover I would prefer solutions like 

_GUICtrlComboBox_SetCurSel($ComboBox, 1)

instead of sending keys.

Link to post
Share on other sites

Hi Gents,

first of all I want to thank you for your support - it's massive what you are doing here!! 👍

It's a lot to read through and I am trying to do my best to understand the things you explain there.

I have now got the result of simplespy.au3 of the combobox I want to control in an automated job:


At least we have an element title: [Deckentyp] class: [ComboBox]

Having the following values for all properties: 
Title is: <Deckentyp>    Class   := <ComboBox>    controltype:= <UIA_ComboBoxControlTypeId>    ,<50003>    , (0000C353)    468;330;159;21
*** Parent Information top down ***
1: Title is: <Gruppe: TESTPROJ; Projekt: 116602;  Plan: EG>    Class   := <XTPMainFrame>    controltype:= <UIA_WindowControlTypeId>    ,<50032>    , (0000C370)    -8;-8;1696;1026
"Title:=Gruppe: TESTPROJ; Projekt: 116602;  Plan: EG;controltype:=UIA_WindowControlTypeId;class:=XTPMainFrame""    
0: Title is: <Deckentyp wählen>    Class   := <#32770>    controltype:= <UIA_WindowControlTypeId>    ,<50032>    , (0000C370)    366;197;284;239
"Title:=Deckentyp wählen;controltype:=UIA_WindowControlTypeId;class:=#32770""    

;~ *** Standard code maintainable ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

_UIA_setVar("oP1","Title:=Gruppe: TESTPROJ; Projekt: 116602;  Plan: EG;controltype:=UIA_WindowControlTypeId;class:=XTPMainFrame")    ;Gruppe: TESTPROJ; Projekt: 116602;  Plan: EG
_UIA_setVar("oP2","Title:=Deckentyp wählen;controltype:=UIA_WindowControlTypeId;class:=#32770")    ;Deckentyp wählen


;~ Actions split away from logical/technical definition above can come from configfiles 



;~ *** Standard code Flexible***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP1=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Gruppe: TESTPROJ; Projekt: 116602;  Plan: EG;controltype:=UIA_WindowControlTypeId;class:=XTPMainFrame", $treescope_children)    
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Deckentyp wählen;controltype:=UIA_WindowControlTypeId;class:=#32770", $treescope_children)    

*** Detailed properties of the highlighted element ***
UIA_title:= <Deckentyp>
UIA_text:= <Deckentyp>
UIA_regexptitle:= <Deckentyp>
UIA_class:= <ComboBox>
UIA_regexpclass:= <ComboBox>
UIA_iaccessiblevalue:= <ELK HAUS DECKEN>
UIA_iaccessiblechildId:= <0>
UIA_id:= <403>
UIA_handle:= <1380650>
UIA_RuntimeId:= <42;1380650>
UIA_BoundingRectangle:= <468;330;159;21>
UIA_ProcessId:= <25412>
UIA_ControlType:= <50003>
UIA_LocalizedControlType:= <Kombinationsfeld>
UIA_Name:= <Deckentyp>
UIA_HasKeyboardFocus:= <False>
UIA_IsKeyboardFocusable:= <True>
UIA_IsEnabled:= <True>
UIA_AutomationId:= <403>
UIA_ClassName:= <ComboBox>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <1380650>
UIA_IsOffscreen:= <False>
UIA_Orientation:= <0>
UIA_FrameworkId:= <Win32>
UIA_IsRequiredForForm:= <False>
UIA_IsDockPatternAvailable:= <False>
UIA_IsExpandCollapsePatternAvailable:= <True>
UIA_IsGridItemPatternAvailable:= <False>
UIA_IsGridPatternAvailable:= <False>
UIA_IsInvokePatternAvailable:= <False>
UIA_IsMultipleViewPatternAvailable:= <False>
UIA_IsRangeValuePatternAvailable:= <False>
UIA_IsScrollPatternAvailable:= <False>
UIA_IsScrollItemPatternAvailable:= <False>
UIA_IsSelectionItemPatternAvailable:= <False>
UIA_IsSelectionPatternAvailable:= <False>
UIA_IsTablePatternAvailable:= <False>
UIA_IsTableItemPatternAvailable:= <False>
UIA_IsTextPatternAvailable:= <False>
UIA_IsTogglePatternAvailable:= <False>
UIA_IsTransformPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <True>
UIA_IsWindowPatternAvailable:= <False>
UIA_ValueIsReadOnly:= <False>
UIA_RangeValueValue:= <0>
UIA_RangeValueIsReadOnly:= <True>
UIA_RangeValueMinimum:= <0>
UIA_RangeValueMaximum:= <0>
UIA_RangeValueLargeChange:= <0>
UIA_RangeValueSmallChange:= <0>
UIA_ScrollHorizontalScrollPercent:= <0>
UIA_ScrollHorizontalViewSize:= <100>
UIA_ScrollVerticalScrollPercent:= <0>
UIA_ScrollVerticalViewSize:= <100>
UIA_ScrollHorizontallyScrollable:= <False>
UIA_ScrollVerticallyScrollable:= <False>
UIA_SelectionCanSelectMultiple:= <False>
UIA_SelectionIsSelectionRequired:= <False>
UIA_GridRowCount:= <0>
UIA_GridColumnCount:= <0>
UIA_GridItemRow:= <0>
UIA_GridItemColumn:= <0>
UIA_GridItemRowSpan:= <1>
UIA_GridItemColumnSpan:= <1>
UIA_DockDockPosition:= <5>
UIA_ExpandCollapseExpandCollapseState:= <0>
UIA_MultipleViewCurrentView:= <0>
UIA_WindowCanMaximize:= <False>
UIA_WindowCanMinimize:= <False>
UIA_WindowWindowVisualState:= <0>
UIA_WindowWindowInteractionState:= <0>
UIA_WindowIsModal:= <False>
UIA_WindowIsTopmost:= <False>
UIA_SelectionItemIsSelected:= <False>
UIA_TableRowOrColumnMajor:= <2>
UIA_ToggleToggleState:= <2>
UIA_TransformCanMove:= <False>
UIA_TransformCanResize:= <False>
UIA_TransformCanRotate:= <False>
UIA_IsLegacyIAccessiblePatternAvailable:= <True>
UIA_LegacyIAccessibleChildId:= <0>
UIA_LegacyIAccessibleName:= <Deckentyp>
UIA_LegacyIAccessibleValue:= <ELK HAUS DECKEN>
UIA_LegacyIAccessibleRole:= <46>
UIA_LegacyIAccessibleState:= <1049600>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:7896,providerId:0x15112A Main:Nested [pid:25412,providerId:0x15112A Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>
UIA_OptimizeForVisualContent:= <False>
UIA_IsObjectModelPatternAvailable:= <False>
UIA_AnnotationAnnotationTypeId:= <60000>
UIA_IsAnnotationPatternAvailable:= <False>
UIA_IsTextPattern2Available:= <False>
UIA_StylesStyleId:= <0>
UIA_StylesFillColor:= <0>
UIA_StylesFillPatternColor:= <0>
UIA_IsStylesPatternAvailable:= <False>
UIA_IsSpreadsheetPatternAvailable:= <False>
UIA_IsSpreadsheetItemPatternAvailable:= <False>
UIA_Transform2CanZoom:= <False>
UIA_IsTransformPattern2Available:= <False>
UIA_LiveSetting:= <0>
UIA_IsTextChildPatternAvailable:= <False>
UIA_IsDragPatternAvailable:= <False>
UIA_DragIsGrabbed:= <False>
UIA_IsDropTargetPatternAvailable:= <False>
UIA_Transform2ZoomLevel:= <1>
UIA_Transform2ZoomMinimum:= <1>
UIA_Transform2ZoomMaximum:= <1>
UIA_IsTextEditPatternAvailable:= <False>
UIA_IsPeripheral:= <False>
UIA_IsCustomNavigationPatternAvailable:= <False>
UIA_PositionInSet:= <0>
UIA_SizeOfSet:= <0>
UIA_Level:= <0>
UIA_LandmarkType:= <0>
UIA_FillType:= <0>
UIA_VisualEffects:= <0>
UIA_IsSelectionPattern2Available:= <False>
UIA_Selection2ItemCount:= <0>
UIA_HeadingLevel:= <80050>
UIA_IsDialog:= <False>



I thought it should work (focussing & highlighting the combobox) when I copy the code part an run it.


Therefore I created the following .au3-file

#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP1=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Gruppe: TESTPROJ; Projekt: 116602;  Plan: EG;controltype:=UIA_WindowControlTypeId;class:=XTPMainFrame", $treescope_children)
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Deckentyp wählen;controltype:=UIA_WindowControlTypeId;class:=#32770", $treescope_children)

Unfortunately it doesn't highlight the combobox ... I am pretty sure it has to do that I did not really specify the combobox in detail.

I guess the line 


needs some more qualification but I don't know how it's done. Is it possible to supply the Automation-ID (i.e. 403) in a parameter?

Or is this analysis completely wrong and the thing should be done in a different way?


Link to post
Share on other sites

It allways depends 😉

Add lines like _UIA_Action($oP1,"highlight") instead of setfocus. 

First see the (grand)parents of your object highlighting. Most likely there are small mismatches in the hierarchy.

yes, you can use id:=403

And this is fine

Local $oCombo=_UIA_getObjectByFindAll($oP0, "id:=403", $treescope_children)

There are many ways to do this so also suggest to look at the examples @larsj made in the forum


Link to post
Share on other sites

Great ... I am getting closer to what I want to achieve 🙂

Another question for me is - how do I find out which _UIA_Actions are available?

For the beginning I am mainly interested in actions around Combobox-Controls. As I wrote in the beginning of this thread it's not possible to use 

_GUICtrlComboBox_SelectString($ComboBox1, "ABC")


_GUICtrlComboBox_SetCurSel($ComboBox1, 2)

The Comboboxes of the application I need to automate do not react to these commands.

An interesting point is that 

$TEST = ControlCommand("Deckentyp wählen", "", "[CLASS:ComboBox; INSTANCE:3]", "GetCurrentSelection")

is working but

ControlCommand("Deckentyp wählen", "", "[CLASS:ComboBox; INSTANCE:3]", "SetCurrentSelection", 2)

is not.

In short words - I am looking for a way to select an item in the combobox which doesn't accept the standard AutoIT methods for this purpose.


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...