Jump to content

Help on UIA Navigation / Walking / Find


zenocon
 Share

Recommended Posts

Consider the following image.  I'm interested in all of the text elements embedded in the last pane called "Power Container".  Unfortunately, this pane is embedded in 8 other panes with the same name and no other identifying characteristics.  I think I can get to the target pane using indexrelative.

Local $powerContainer = _UIA_getObjectByFindAll($cPowerMain, "controltype:=UIA_PaneControlTypeId;Name:=Power Container;indexrelative:=8", $treescope_subtree) 

If Not IsObj($powerContainer) Then Return ConsoleWrite("Could not find Power Container pane")

So, now I have the pane, but I want to target individual text elements.  They do seemingly have AutomationIds so I think I can use that as a selector.  Problem is I'm building a fake WinForms GUI to test with since I don't have access to the real UI to automate for testing purposes, and with WinForms, there is no way to set the AutomationId.  There is no other identifying information on these text elements.  Their Name property contains the actual data, which varies.  Except for the labels that sit in from of them.

The way it is built it looks like this:
 

Quote

 

// This is the Label and the name is static (never changes) so I can easily select on it

Name: "Tag#"
ControlType: UIA_TextControlTypeId (0xC364)

// This is the data I want which is dynamic; this element Is the next sibling of the element above

Name: "6741 "
ControlType: UIA_TextControlTypeId (0xC364)

 

My question is this: I know I can select to get the one with the static label value "Tag#"

Local $tagLabel = _UIA_getObjectByFindAll($powerContainer, "controltype:='UIA_TextControlTypeId;Name:=Tag#", $treescope_subtree)

Now, what I want to do is navigate to get the next sibling of this element.  It doesn't look like the API allows me to do this?  I think what I have to do is get a RawViewWalker and just iterate through all of them and inspect each one and figure out if it is what I'm looking for.   Does this seem correct?

Is there a better way to achieve this?

unnamed.png

Link to comment
Share on other sites

1.Findall is easiest to get them all in an array

2.indexrelative can work from any other adjacent element that has recognizable properties

3. Treewalker is little more complex to write but examples are hopefully clear as part of uiautomation examples.zip, could be a little faster as its then not collecting all elements.

For me it looks like inspect.exe recognizes nicely so do not understand why you would like to make an overlay. If you want that i would advice to use autoit for that with guicreate commands.

Link to comment
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
 Share

×
×
  • Create New...