Debremus Posted July 14, 2016 Share Posted July 14, 2016 I'm trying to reference a particular frame, and all of the frames in the application have matching properties. A DumpThemAll gets 3 elements with the following: Title is: <> Class := <> controltype:= <UIA_TableControlTypeId> ,<50036> , (0000C374) , acceleratorkey:= <> , automationid:= <> There is no way to uniquely reference the elements. Is there any function to reference the 2nd or 3rd found element? Link to comment Share on other sites More sharing options...
MichaelHB Posted July 14, 2016 Share Posted July 14, 2016 (edited) Try this: _UIA_getObjectByFindAll($oOBJ,"controltype:=" & $UIA_TableControlTypeId & ";indexrelative:=2", $treescope_subtree) Edited July 14, 2016 by MichaelHB Link to comment Share on other sites More sharing options...
junkew Posted July 14, 2016 Share Posted July 14, 2016 Index should do the job. Indexrelative is relative to the object found as first. 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...
Debremus Posted July 19, 2016 Author Share Posted July 19, 2016 This didn't work for me. It searched the subtree for all elements for the property "indexrelative", but all elements showed indexrelative as being 0. Any ideas? Link to comment Share on other sites More sharing options...
Debremus Posted July 19, 2016 Author Share Posted July 19, 2016 Disregard, I came up with a solution based on DumpThemAll: <code> Func _UIA_GetElementNumber($oElementStart, $treeScope, $elementNum) ;~ Get result with findall function alternative could be the treewalker Local $pCondition, $pTrueCondition, $oCondition, $oAutomationElementArray Local $pElements, $iLength, $i local $dumpStr local $tStr $dumpStr="<treedump>" $dumpStr=$dumpStr & "<treeheader>***** Object Found At Position *****</treeheader>" ;~ _UIA_LOG("<treedump>" & @CRLF) ;~ _UIA_LOG("***** Dumping tree *****" & @CRLF) ;~ $UIA_oUIAutomation.CreateTrueCondition($pTrueCondition) ;~ $oCondition=ObjCreateInterface($pTrueCondition, $sIID_IUIAutomationCondition,$dtagIUIAutomationCondition) $oElementStart.FindAll($treeScope, $UIA_oTRUECondition, $pElements) $oAutomationElementArray = ObjCreateInterface($pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) ;~ If there are no childs found then there is nothing to search If _UIA_IsElement($oAutomationElementArray) Then ;~ All elements to inspect are in this array $oAutomationElementArray.Length($iLength) Else $dumpStr=$dumpStr & "<fatal>***** FATAL:???? _UIA_DumpThemAll no childarray found ***** </fatal>" ;~ _UIA_LOG("***** FATAL:???? _UIA_DumpThemAll no childarray found *****" & @CRLF, $UIA_Log_Wrapper) $iLength = 0 EndIf $oAutomationElementArray.GetElement($elementNum, $UIA_pUIElement) $UIA_oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $tStr="Title is: <" & _UIA_getPropertyValue($UIA_oUIElement, $UIA_NamePropertyId) & ">" & @TAB _ & "Class := <" & _UIA_getPropertyValue($UIA_oUIElement, $UIA_ClassNamePropertyId) & ">" & @TAB _ & "controltype:= " _ & "<" & _UIA_getControlName(_UIA_getPropertyValue($UIA_oUIElement, $UIA_ControlTypePropertyId)) & ">" & @TAB _ & ",<" & _UIA_getPropertyValue($UIA_oUIElement, $UIA_ControlTypePropertyId) & ">" & @TAB _ & ", (" & Hex(_UIA_getPropertyValue($UIA_oUIElement, $UIA_ControlTypePropertyId)) & ")" & @TAB _ & ", acceleratorkey:= <" & _UIA_getPropertyValue($UIA_oUIElement, $UIA_AcceleratorKeyPropertyId) & ">" & @TAB _ & ", automationid:= <" & _UIA_getPropertyValue($UIA_oUIElement, $UIA_AutomationIdPropertyId) & ">" & @TAB $tstr=_UIA_EncodeHTMLString($tStr) return $UIA_oUIElement $dumpStr=$dumpStr & "<elementinfo>" & $tStr & "</elementinfo>" ;~ _UIA_LOG($tStr) $dumpStr=$dumpStr & "</treedump>" _UIA_LOG($dumpStr) EndFunc </code> Link to comment Share on other sites More sharing options...
junkew Posted July 19, 2016 Share Posted July 19, 2016 (edited) edit: 0 iindexed so third one = 2 _UIA_getObjectByFindAll($oOBJ,"controltype:=table;instance:=2", $treescope_subtree) In general it should be programmed like controltype:=Table;index:=2 or controltype:=Table;instance:=2 Its in this piece of code happening of uiawrappers and you should see it in the log that it skippes other instances ;~ Just reset found status and continue in the loop till the right one is found If $relIndex <> 0 Then $matchCount = $matchCount + 1 If $matchCount <> $relIndex Then $iMatch = 0 _UIA_LOG(" Found and skipped due to index position: <" & $relIndex & " " & $matchCount & " " & $tmpStr & @CRLF, $UIA_Log_Wrapper) Else $iMatch = 1 EndIf EndIf other special properties are defined in the array as below ["indexrelative", $__UIA_SpecialProperty], _ ; Special propertyname ["index", $__UIA_SpecialProperty], _ ; Special propertyname ["instance", $__UIA_SpecialProperty], _ ; Special propertyname ["title", $UIA_NamePropertyId], _ ; Alternate propertyname ["text", $UIA_NamePropertyId], _ ; Alternate propertyname ["regexptitle", $UIA_NamePropertyId], _ ; Alternate propertyname ["class", $UIA_ClassNamePropertyId], _ ; Alternate propertyname ["regexpclass", $UIA_ClassNamePropertyId], _ ; Alternate propertyname ["iaccessiblevalue", $UIA_LegacyIAccessibleValuePropertyId], _ ; Alternate propertyname ["iaccessiblechildId", $UIA_LegacyIAccessibleChildIdPropertyId], _ ; Alternate propertyname ["id", $UIA_AutomationIdPropertyId], _ ; Alternate propertyname ["handle", $UIA_NativeWindowHandlePropertyId], _ ; Alternate propertyname Edited July 19, 2016 by junkew 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...
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