Jump to content

Recommended Posts

Posted

Am i right to think that it is a custom control item and it has a listbox inside it?

I am trying to write a UI automation script to get the value of "9" .  Grid Control Pattern doesnt work, UIA_SelectionPatternId doesnt work (returns error on IsObj).  $UIA_SelectionItemPatternId WORKS but i still struggle how to get the selection value. 

 

Here is my code .  As you can see there are 4 $UIA_CustomControlTypeId box in which the one i am interested in is the 4th one so i need to use FindAll and iterate through the Array. $oSelectionItemPattern1 returns OK but GetCurrentSelection doesnt return anything.

 

---- start finding ListItem controls

Local $pCondition3
  $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListItemControlTypeId, $pCondition3 )
  If Not $pCondition3 Then Return ConsoleWrite( "$pCondition3 ERR" & @CRLF )
  ConsoleWrite( "$pCondition3 OK" & @CRLF )



Local $pList3
$oWindow1.FindAll( $TreeScope_Descendants, $pCondition3, $pList3 )

Local $oUIElementArray1, $iLength1 ; $pElements is a pointer to an UI Automation element array
  $oUIElementArray1 = ObjCreateInterFace( $pList3, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray )
  $oUIElementArray1.Length( $iLength1 )
  If Not $iLength1 Then Return ConsoleWrite( "$iLength1 = 0 ERR" & @CRLF )
  ConsoleWrite( "$iLength1 = " & $iLength1 & @CRLF )


 Local $pElement1, $oElement1, $pSelectionItemPattern1, $oSelectionItemPattern1, $a
  For $i = 0 To $iLength1 - 1
    $oUIElementArray1.GetElement( $i, $pElement1 )
    $oElement1 = ObjCreateInterface( $pElement1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )

    $oElement1.GetCurrentPattern( $UIA_SelectionItemPatternId, $pSelectionItemPattern1 )
$oSelectionItemPattern1 = ObjCreateInterface( $pSelectionItemPattern1, $sIID_IUIAutomationSelectionItemPattern, $dtagIUIAutomationSelectionItemPattern )
  If Not IsObj( $oSelectionItemPattern1 ) Then Return ConsoleWrite( "$oSelectionItemPattern1 ERR" & @CRLF )
  ConsoleWrite( "$oSelectionItemPattern1 OK" & @CRLF )

  $oSelectionItemPattern1.GetCurrentSelection($a)
ConsoleWrite(  $a  & @CRLF )



  Next

 

UI1.png

UI2.png

UI3.png

Posted

The fact that it's a custom control means that the control cannot be identified as one of the other controls in module UIA_ControlTypeIds in UIA_Constants.au3 and is therefore defined as a custom control.

Especially on web pages there are often many custom controls because some web elements do not directly correspond to UI Automation elements. So I'm guessing it's a webpage you're automating.

The child element is a list item control and not a list control. A list item control and a list control are two different controls as you can see in UIA_Constants.au3.

To read the value of the list item control below the custom control named "doc", you should check if $UIA_LegacyIAccessibleValuePropertyId (not shown in the image) contains the value.

If it doesn't contain the value, it's probably easiest to select the value through the SelectionItemPattern and then copy the value with Ctrl+Insert.

The custom control named "doc" seems to be unique in the image. If you start by identifying this control and then the list item control which is the only child element you don't need to use an element array.

Posted (edited)
On 10/6/2019 at 9:01 PM, LarsJ said:

The fact that it's a custom control means that the control cannot be identified as one of the other controls in module UIA_ControlTypeIds in UIA_Constants.au3 and is therefore defined as a custom control.

Especially on web pages there are often many custom controls because some web elements do not directly correspond to UI Automation elements. So I'm guessing it's a webpage you're automating.

The child element is a list item control and not a list control. A list item control and a list control are two different controls as you can see in UIA_Constants.au3.

To read the value of the list item control below the custom control named "doc", you should check if $UIA_LegacyIAccessibleValuePropertyId (not shown in the image) contains the value.

If it doesn't contain the value, it's probably easiest to select the value through the SelectionItemPattern and then copy the value with Ctrl+Insert.

The custom control named "doc" seems to be unique in the image. If you start by identifying this control and then the list item control which is the only child element you don't need to use an element array.

No its not a webpage, its an enterprise software. If its a webpage i would have a much easier time using tampermonkey.

 

UIA_LegacyIAccessibleValuePropertyId  is unfortunately empty

image.png.92148ecd249c0478ebbff8dd8632fd1f.png

 

so that leaves me with only this solution?

" select the value through the SelectionItemPattern and then copy the value with Ctrl+Insert."

 

Edited by cyxstudio

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...