LaurentR Posted November 18, 2021 Share Posted November 18, 2021 Hi everybody, I try to select an item in a qt combo box. With UIASpy : I have a QCombox (type $UIA_ComboBoxControlTypeId) with a List QComboBoxListView (type $UIA_ListControlTypeId) and several item of ListItem (type $UIA_ListItemControlTypeId). I wrote a function to select an item, but it's note working. can you help me. thanks in advance Func qtAutoitComboBox_SetVal($oDialog,$aValue) if _UIA_IsElement($oDialog) then ; _UIA_action($oDialog,"leftclick") local $ssearch="ControlType:=UIA_ListControlTypeId;class:=QComboBoxListView" local $oDialogChild=_UIA_getObjectByFindAll($oDialog,$ssearch, $treescope_subtree) if _UIA_IsElement($oDialogChild) then Local $pElements Local $oAutomationElementArray Local $iLength $oDialogChild.FindAll($treescope_subtree, $UIA_oTRUECondition, $pElements) $oAutomationElementArray = ObjCreateInterface($pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) If _UIA_IsElement($oAutomationElementArray) Then $oAutomationElementArray.Length($iLength) For $i = 0 To $iLength-1 Step 1 Local $oElement Local $pElement $oAutomationElementArray.GetElement($i, $oElement) $pElement = ObjCreateInterface($oElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) _GUICtrlComboBox_SetCurSel($oDialogChild,5) If _UIA_IsElement($pElement) AND _UIA_getPropertyValue($pElement, $UIA_ClassNamePropertyId) <> "QComboBoxListView" Then Local $pSelectionItemPattern, $oSelectionItemPattern $pElement.GetCurrentPattern( $UIA_SelectionItemPatternId, $pSelectionItemPattern ) $oSelectionItemPattern = ObjCreateInterface( $pSelectionItemPattern, $sIID_IUIAutomationSelectionItemPattern, $dtagIUIAutomationSelectionItemPattern ) If _UIA_IsElement( $oSelectionItemPattern ) Then if _ArraySearch($aValue,_UIA_getPropertyValue($pElement, $UIA_NamePropertyId)) <> -1 then $oSelectionItemPattern.Select() else $oSelectionItemPattern.RemoveFromSelection() endif endif endif Next endif endif endif EndFunc ;==>qtAutoitComboBox_SetVal Link to comment Share on other sites More sharing options...
junkew Posted November 20, 2021 Share Posted November 20, 2021 A little more specific. Is the uiaspy highlighting what you need? Is it showing that it supports the selection pattern? LarsJ 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
LaurentR Posted November 22, 2021 Author Share Posted November 22, 2021 Yes I got for the QComboBoxListView Control Patterns (element actions) $UIA_IsLegacyIAccessiblePatternAvailablePropertyId True (LegacyIAccessiblePattern) $UIA_IsSelectionPatternAvailablePropertyId True (SelectionPattern) $UIA_IsValuePatternAvailablePropertyId True (ValuePattern) and for the item ListItem Control Patterns (element actions) $UIA_IsInvokePatternAvailablePropertyId True (InvokePattern) $UIA_IsLegacyIAccessiblePatternAvailablePropertyId True (LegacyIAccessiblePattern) $UIA_IsSelectionItemPatternAvailablePropertyId True (SelectionItemPattern) $UIA_IsValuePatternAvailablePropertyId True (ValuePattern) Link to comment Share on other sites More sharing options...
junkew Posted November 23, 2021 Share Posted November 23, 2021 I am not sure if in UIASpy you have the option to trigger the event to see if it works at all Try inspect.exe it has an option to execute patterns if they exist so you can see if the selection pattern in itself works (QT Widgets do have not all support in a proper way) _GUICtrlComboBox_SetCurSel($oDialogChild,5) in general do not mix UIA and AutoIt functions Is your element of interest found by your code, to make sure add a highlight element or consolewrite of some properties so you can debug https://doc.qt.io/qt-5/accessible-qwidget.html gives an indication on how QT has done things with accessibility FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
LarsJ Posted November 24, 2021 Share Posted November 24, 2021 Look at section 11. SelectionItem Control Pattern in the Patterns (actions) post. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now