Sign in to follow this  
Followers 0
Kharizmah

UIAutomation access to First Child

5 posts in this topic

I would like to access a list view object and then get the value for the first child.
However, there doesn't seem to be a property value available though it shows in Inspect.

I figured it shouldn't be too difficult to add

    ["FirstChild", $UIA_FirstChildPropertyId]_  to UIAWrappers.au3

 and then a Global Variable to  CUIAutomation2.au3. However,  I'm not sure how you figure out the Id# for this Property.

@Junkew Can you help me figure that out?

FirstChild.png

Share this post


Link to post
Share on other sites



as told in iuiautomation thread add more information from simplespy output.

Not sure but I think you first have to get your list object and then with a treewalker you can get first and last child

As far as I am aware there is not a property for First or Last child

see https://msdn.microsoft.com/en-us/library/windows/desktop/ee671425(v=vs.85).aspx

Share this post


Link to post
Share on other sites

I thought maybe there was because it is listed at the bottom, using WinSDK_Inspect_exe_x86.exe

It's not that I am having trouble - accessing the field or seeing if it is an element of the list -  using tree walker; it's that I actually need to know if it's listed as the first child.

I checked the link you sent. 

I will try accessing the link and using the FindFirst() method.

 

Share this post


Link to post
Share on other sites

Okay I have tried:

$obj.GetFirstChild

$obj.GetFirstChildElement

$obj.FindFirstChild

The problem is all of these seem to want you to point toward a property in the object,  such as $UIA_NamePropertyId.
This makes perfect sense, which is why I was wondering if I could access that field in Inspect.exe listed as FirstChild.  The Element in FirstChild is the data I desire.

I could even deal with getting access to the "property" listed here as Children. 

When I use SimpleSpy.au3, I do not see a property that has any information that I can use to narrow it's position within the subtree of ListView.

If you have any ideas, please let me know.

Share this post


Link to post
Share on other sites

So I continued to extensively research your code and managed to get the value of the first child by accessing the listbox path, getting the firstObject, and then pulling its value.

Local $o_listBox  =searchForPathByAutoId(...

Local $firstElement = _UIA_getFirstObjectOfElement($o_listBox...

Local $firstElementValue = _UIA_getPropertyValue($firstElement, $UIA_NamePropertyId)

 

Thanks for guiding me along the way :D

Share this post


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
Sign in to follow this  
Followers 0

  • Similar Content

    • bobmcrae
      By bobmcrae
      I am experimenting with UIAWrappers.au3 from junkew to complete an application which presents absolutely no control information using AutoIT Window Info.  While I am able to complete the form successfully, I am not happy with the speed.  As a benchmark, the simple Send method occurs in far less than 1-second, but the UIAutomation approach takes 3-seconds.  I am wondering whether performance gains may be achieved by specifying the controls more precisely; but I am unsure how to do that.  I was able to speed things up a bit by setting $UIA_DefaultWaitTime=0.  The controls of interest are 5-levels deep, as show in the simplespy output below.  It seems I do get faster response by specifying the target/top-level window, as show in the code below.  Any ideas?
      #include "UIAWrappers.au3" _UIA_setVar("Global.Debug", False) _UIA_setVar("Global.Debug.File", False) _UIA_setVar("Global.Highlight", False) _UIA_setVar("DPN","Title:=NC-stat DPNCheck Communicator;controltype:=UIA_WindowControlTypeId;class:=Window") _UIA_action('DPN','setFocus') _UIA_setVar("DPN.firstName","AutomationId:=txtFirstName") _UIA_setVar("DPN.lastName", "AutomationId:=txtLastName") _UIA_Action('DPN.lastName','setvalue','last name') _UIA_setVar("DPN.ID", "AutomationId:=txtSubjectId") _UIA_setVar("DPN.DOB", "AutomationId:=PART_TextBox") _UIA_setVar("DPN.Ft", "AutomationId:=txtSubjectHeight") _UIA_setVar("DPN.In", "AutomationId:=txtSubjectHeight2") _UIA_Action('DPN.firstName','setvalue','first name') _UIA_Action('DPN.ID','setvalue','ID012345') _UIA_Action('DPN.DOB','setvalue','1/31/1932') _UIA_Action('DPN.Ft','setvalue','6') _UIA_Action('DPN.In','setvalue','1') SimpleSpy output:
      ;~ *** Standard code *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP4=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=NC-stat DPNCheck Communicator;controltype:=UIA_WindowControlTypeId;class:=Window", $treescope_children) _UIA_Action($oP4,"setfocus") Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Frame", $treescope_children) Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_TabControlTypeId;class:=TabControl", $treescope_children) Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=Patient;controltype:=UIA_TabItemControlTypeId;class:=TabItem", $treescope_children) Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Frame", $treescope_children) ;~ First find the object in the parent before you can do something ;~$oUIElement=_UIA_getObjectByFindAll(".mainwindow", "title:=;ControlType:=UIA_EditControlTypeId", $treescope_subtree) Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=;ControlType:=UIA_EditControlTypeId", $treescope_subtree) _UIA_action($oUIElement,"click")