Jump to content
rmckay

Need help with $UIA_NativeWindowHandlePropertyId

Recommended Posts

Posted (edited)

Hello,

I'm trying to automate the settings of combo boxes in a program. The combo boxes are child windows of two different windows.  They have the similar but different titles so I can locate them using 'WinList('ES 06-20-NT8')'.  After I locate the windows I need to change the selection in a combo box on each.  I initially tried to use the window handle of the respective windows to create an element for each with '$oUIAutomation.ElementFromHandle( $hWindow, $pWindow )'.  The objects will create and I can read the contents of the combo boxes. When I try to change the value using   .SetValue() the combo box in only one of the windows changes.  WinActivate() or .SetFocus() will change the active window but the combo box will still only change in one of the windows.  Next attempt is to use the '$UIA_AutomationIdPropertyId' & ' $UIA_NativeWindowHandlePropertyId  to create an ''AndCondition'.  I've included the script for this.  The problem now is that each time the program restarts the value for '$UIA_NativeWindowHandlePropertyId ' changes.  If I get the current value using UIASpy and input the values into the script it will work.  I've searched every place I can think of to find out how I can get the current value for '$UIA_NativeWindowHandlePropertyId ' and automate it.  Any suggestions are greatly appreciated.

822558396_AutoItForumPost-FindMultipleWindows01.thumb.png.0d34cb032a5a52d683cce47fa993c725.png1057186657_AutoItForumPost-FindMultipleWindows02.thumb.png.d5c90f428f90d8e1aad33e55259f8391.png

 

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7


#include "C:\Users\Rod\Documents\AutoIt\Include\UIA_Constants.au3" ; Can be copied from UIASpy Includes folder
#include "C:\Users\Rod\Documents\AutoIt\Include\CUIAutomation2WithDuplicateConstantsRemoved.au3"
#include 'Array.au3'

Opt("MustDeclareVars", 1)

Example()

Func Example()
    ; creates an array with 3 rows
    Local $aArr = WinList('ES 06-20-NT8')
    _ArrayDisplay($aArr)
    
    For $i = 1 To UBound($aArr) - 1
        ConsoleWrite($aArr[$i][0] & '  ' & $aArr[$i][1] & @CRLF)
    Next
    
    ; tried window handle for property condition in '$UIA_NativeWindowHandlePropertyId' but it doesn't work
    ; Local $hWnd = WinGetHandle($aArr[1][0])
    ; Create UI Automation object
    Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation8, $sIID_IUIAutomation5, $dtag_IUIAutomation5)
    If Not IsObj($oUIAutomation) Then Return ConsoleWrite("$oUIAutomation ERR" & @CRLF)
    ConsoleWrite("$oUIAutomation OK" & @CRLF)

    ; Get Desktop element
    Local $pDesktop, $oDesktop
    $oUIAutomation.GetRootElement($pDesktop)
    $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement8, $dtag_IUIAutomationElement8)
    If Not IsObj($oDesktop) Then Return ConsoleWrite("$oDesktop ERR" & @CRLF)
    ConsoleWrite("$oDesktop OK" & @CRLF)

    ; --- Find window/control ---

    ConsoleWrite("--- Find window/control ---" & @CRLF)
    Local $pCondition0, $pCondition1, $pAndCondition1
    $oUIAutomation.CreatePropertyCondition($UIA_AutomationIdPropertyId, "accountComboBox", $pCondition0)
    $oUIAutomation.CreatePropertyCondition($UIA_NativeWindowHandlePropertyId, 0x001506B6, $pCondition1)
    $oUIAutomation.CreateAndCondition($pCondition0, $pCondition1, $pAndCondition1)
    If Not $pAndCondition1 Then Return ConsoleWrite("$pAndCondition1 ERR" & @CRLF)
    ConsoleWrite("$pAndCondition1 OK" & @CRLF)

    Local $pComboBox1, $oComboBox1
    $oDesktop.FindFirst($TreeScope_Descendants, $pAndCondition1, $pComboBox1)
    $oComboBox1 = ObjCreateInterface($pComboBox1, $sIID_IUIAutomationElement8, $dtag_IUIAutomationElement8)
    If Not IsObj($oComboBox1) Then Return ConsoleWrite("$oComboBox1 ERR" & @CRLF)
    ConsoleWrite("$oComboBox1 OK" & @CRLF)

    ; --- LegacyIAccessible Pattern (action) Object ---

    ConsoleWrite("--- LegacyIAccessible Pattern (action) Object ---" & @CRLF)

    Local $pLegacyIAccessiblePattern1, $oLegacyIAccessiblePattern1
    $oComboBox1.GetCurrentPattern($UIA_LegacyIAccessiblePatternId, $pLegacyIAccessiblePattern1)
    $oLegacyIAccessiblePattern1 = ObjCreateInterface($pLegacyIAccessiblePattern1, $sIID_IUIAutomationLegacyIAccessiblePattern, $dtag_IUIAutomationLegacyIAccessiblePattern)
    If Not IsObj($oLegacyIAccessiblePattern1) Then Return ConsoleWrite("$oLegacyIAccessiblePattern1 ERR" & @CRLF)
    ConsoleWrite("$oLegacyIAccessiblePattern1 OK" & @CRLF)

    ; --- LegacyIAccessible Pattern (action) Methods ---

    ConsoleWrite("--- LegacyIAccessible Pattern (action) Methods ---" & @CRLF)
    Local $sValue
    $oLegacyIAccessiblePattern1.CurrentValue($sValue)
    ConsoleWrite("$oLegacyIAccessiblePattern1.CurrentValue() = " & $sValue & @CRLF)

    ; --- Value Pattern (action) Object ---

    ConsoleWrite("--- Value Pattern (action) Object ---" & @CRLF)

    Local $pValuePattern1, $oValuePattern1
    $oComboBox1.GetCurrentPattern($UIA_ValuePatternId, $pValuePattern1)
    $oValuePattern1 = ObjCreateInterface($pValuePattern1, $sIID_IUIAutomationValuePattern, $dtag_IUIAutomationValuePattern)
    If Not IsObj($oValuePattern1) Then Return ConsoleWrite("$oValuePattern1 ERR" & @CRLF)
    ConsoleWrite("$oValuePattern1 OK" & @CRLF)

    ; --- Value Pattern (action) Methods ---

    ConsoleWrite("--- Value Pattern (action) Methods ---" & @CRLF)

    $oValuePattern1.SetValue('NT8-Sim 03 Tue')
    ConsoleWrite("$oValuePattern1.SetValue()" & @CRLF)
    $oLegacyIAccessiblePattern1.CurrentValue($sValue)
    ConsoleWrite("$oLegacyIAccessiblePattern1.CurrentValue() = " & $sValue & @CRLF)


    ; --- Find window/control ---

    ConsoleWrite("--- Find window/control ---" & @CRLF)

    ; --- Find window/control ---

    ConsoleWrite("--- Find window/control ---" & @CRLF)

    $oUIAutomation.CreatePropertyCondition($UIA_AutomationIdPropertyId, "accountComboBox", $pCondition0)
    $oUIAutomation.CreatePropertyCondition($UIA_NativeWindowHandlePropertyId, 0x0010069E, $pCondition1)
    $oUIAutomation.CreateAndCondition($pCondition0, $pCondition1, $pAndCondition1)
    If Not $pAndCondition1 Then Return ConsoleWrite("$pAndCondition1 ERR" & @CRLF)
    ConsoleWrite("$pAndCondition1 OK" & @CRLF)

    $oDesktop.FindFirst($TreeScope_Descendants, $pAndCondition1, $pComboBox1)
    $oComboBox1 = ObjCreateInterface($pComboBox1, $sIID_IUIAutomationElement8, $dtag_IUIAutomationElement8)
    If Not IsObj($oComboBox1) Then Return ConsoleWrite("$oComboBox1 ERR" & @CRLF)
    ConsoleWrite("$oComboBox1 OK" & @CRLF)

    ; --- LegacyIAccessible Pattern (action) Object ---

    ConsoleWrite("--- LegacyIAccessible Pattern (action) Object ---" & @CRLF)

    $oComboBox1.GetCurrentPattern($UIA_LegacyIAccessiblePatternId, $pLegacyIAccessiblePattern1)
    $oLegacyIAccessiblePattern1 = ObjCreateInterface($pLegacyIAccessiblePattern1, $sIID_IUIAutomationLegacyIAccessiblePattern, $dtag_IUIAutomationLegacyIAccessiblePattern)
    If Not IsObj($oLegacyIAccessiblePattern1) Then Return ConsoleWrite("$oLegacyIAccessiblePattern1 ERR" & @CRLF)
    ConsoleWrite("$oLegacyIAccessiblePattern1 OK" & @CRLF)

    ; --- LegacyIAccessible Pattern (action) Methods ---

    ConsoleWrite("--- LegacyIAccessible Pattern (action) Methods ---" & @CRLF)

    $oLegacyIAccessiblePattern1.CurrentValue($sValue)
    ConsoleWrite("$oLegacyIAccessiblePattern1.CurrentValue()" & $sValue & @CRLF)

    ; --- Value Pattern (action) Object ---

    ConsoleWrite("--- Value Pattern (action) Object ---" & @CRLF)

    $oComboBox1.GetCurrentPattern($UIA_ValuePatternId, $pValuePattern1)
    $oValuePattern1 = ObjCreateInterface($pValuePattern1, $sIID_IUIAutomationValuePattern, $dtag_IUIAutomationValuePattern)
    If Not IsObj($oValuePattern1) Then Return ConsoleWrite("$oValuePattern1 ERR" & @CRLF)
    ConsoleWrite("$oValuePattern1 OK" & @CRLF)

    ; --- Value Pattern (action) Methods ---

    ConsoleWrite("--- Value Pattern (action) Methods ---" & @CRLF)

    $oValuePattern1.SetValue('NT8-Sim 03 Tue')
    ConsoleWrite("$oValuePattern1.SetValue()" & @CRLF)
    $oLegacyIAccessiblePattern1.CurrentValue($sValue)
    ConsoleWrite("$oLegacyIAccessiblePattern1.CurrentValue() = " & $sValue & @CRLF)

EndFunc   ;==>Example

 

Output from script

ES 06-20-NT8-Sim 02 Mon  0x05D50AAA
ES 06-20-NT8-Sim04 Wed  0x001208B8
$oUIAutomation OK
$oDesktop OK
--- Find window/control ---
$pAndCondition1 OK
$oComboBox1 OK
--- LegacyIAccessible Pattern (action) Object ---
$oLegacyIAccessiblePattern1 OK
--- LegacyIAccessible Pattern (action) Methods ---
$oLegacyIAccessiblePattern1.CurrentValue() = NT8-Sim 02 Mon
--- Value Pattern (action) Object ---
$oValuePattern1 OK
--- Value Pattern (action) Methods ---
$oValuePattern1.SetValue()
$oLegacyIAccessiblePattern1.CurrentValue() = NT8-Sim 03 Tue
--- Find window/control ---
--- Find window/control ---
$pAndCondition1 OK
$oComboBox1 OK
--- LegacyIAccessible Pattern (action) Object ---
$oLegacyIAccessiblePattern1 OK
--- LegacyIAccessible Pattern (action) Methods ---
$oLegacyIAccessiblePattern1.CurrentValue()NT8-Sim04 Wed
--- Value Pattern (action) Object ---
$oValuePattern1 OK
--- Value Pattern (action) Methods ---
$oValuePattern1.SetValue()
$oLegacyIAccessiblePattern1.CurrentValue() = NT8-Sim 03 Tue

Thanks in advance.

Edited by rmckay
Script below 3rd commented line was in red. I apologized and when I submitted the article the script was in normal color.

Share this post


Link to post
Share on other sites

junkew,

Thanks for taking the time to look at this.  I'll put the code together and post it.  It'll have it here later today.

 

Share this post


Link to post
Share on other sites

Hi junkew,

I was able to simplify the problem as the windows and the combo boxes they contain are direct descendants of the desktop.  Using .FindAll() gets them without a problem.  Then it's just am matter of setting a new value. I do have another question.  You mention using nextchild to descend the tree view.  I'm pretty new to Autoit still and have not attempted to locate items above or below using tree view.  Can I ascend the tree from the elements I located and end up with the name of the respective windows?

Thanks again

Opt("MustDeclareVars", 1)
Example()

Func Example()

    ; Create UI Automation object
    Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation8, $sIID_IUIAutomation5, $dtag_IUIAutomation5)
    If Not IsObj($oUIAutomation) Then Return ConsoleWrite("$oUIAutomation ERR" & @CRLF)
    ConsoleWrite("$oUIAutomation OK" & @CRLF)
    
    ; Get Desktop element
    Local $pDesktop, $oDesktop
    $oUIAutomation.GetRootElement($pDesktop)
    $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement8, $dtag_IUIAutomationElement8)
    If Not IsObj($oDesktop) Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oDesktop ERR" & @CRLF)
    ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oDesktop OK" & @CRLF)

    Local $pConditionComboBox
    $oUIAutomation.CreatePropertyCondition($UIA_AutomationIdPropertyId, "accountComboBox", $pConditionComboBox)
    If Not $pConditionComboBox Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $pConditionComboBox ERR" & @CRLF)
    ConsoleWrite(':' & @ScriptLineNumber & ':' & " $pConditionComboBox OK" & @CRLF)

    Local $pElements
    $oDesktop.FindAll($TreeScope_Descendants, $pConditionComboBox, $pElements)

    Local $oUIElementArray1, $iLength1 ; $pElements is a pointer to an UI Automation element array
    $oUIElementArray1 = ObjCreateInterface($pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray)
    $oUIElementArray1.Length($iLength1)
    Local $pElement1, $oElement1, $sValue1
    For $i = 0 To $iLength1 - 1
        $oUIElementArray1.GetElement($i, $pElement1)
        $oElement1 = ObjCreateInterface($pElement1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)

        Local $pLegacyIAccessiblePattern1, $oLegacyIAccessiblePattern1
        $oElement1.GetCurrentPattern($UIA_LegacyIAccessiblePatternId, $pLegacyIAccessiblePattern1)
        $oLegacyIAccessiblePattern1 = ObjCreateInterface($pLegacyIAccessiblePattern1, $sIID_IUIAutomationLegacyIAccessiblePattern, $dtag_IUIAutomationLegacyIAccessiblePattern)

        $oLegacyIAccessiblePattern1.CurrentValue($sValue1)
        ConsoleWrite(':' & @ScriptLineNumber & ':' & ' ' & $i & " $sValue1 = " & $sValue1 & @CRLF)

        Local $pLegacyPatternInstrumentBox, $oLegacyPatternInstrumentBox
        $oElement1.GetCurrentPattern($UIA_LegacyIAccessiblePatternId, $pLegacyPatternInstrumentBox)
        $oLegacyPatternInstrumentBox = ObjCreateInterface($pLegacyPatternInstrumentBox, $sIID_IUIAutomationLegacyIAccessiblePattern, $dtag_IUIAutomationLegacyIAccessiblePattern)

        Local $sValueValue1
        $oElement1.GetCurrentPropertyValue($UIA_ValueValuePropertyId, $sValueValue1)
        ConsoleWrite(':' & @ScriptLineNumber & ':' & " $sValueValue1 = " & $sValueValue1 & @CRLF)

        Local $sMyIntInputnput = 'NT8-Sim 07 Sat'
        $oLegacyPatternInstrumentBox.SetValue($sMyIntInputnput)

        $oElement1.GetCurrentPropertyValue($UIA_ValueValuePropertyId, $sValueValue1)
        ConsoleWrite(':' & @ScriptLineNumber & ':' & " $sValueValue1 = " & $sValueValue1 & @CRLF)


    Next

EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites
Posted (edited)

The uiautomation is not AutoIt related just wrapped the ui automation from microsoft. With treewalker examples you can walk childs parents etc. Search for walker in the examples.zip but also in the forum will give you hits. @LarsJ has written nice detailed threads on usage of the whole ui automation api.

Simplespy source will give you an idea how to walk to (grand)parents

 

Edited by junkew

Share this post


Link to post
Share on other sites

Hi @junkew,

Thanks for the guidance.  I'm working my way through both you and @LarsJ forum posts.  Starting to get the big picture but it's been a steep curve.

Thanks

Share this post


Link to post
Share on other sites

Just ask and let us know where you see the complexity so I can change the introduction post and/or examples

Simple explanation

  1. A desktop screen has a list of objects
  2. Iterate thru arraylist of objects till object is found based on a property value

 

Complexity

  1. A desktop screen is a hierarchy of objects
    1. Most people I explain automation I ask make a hierarchy picture of your objects on a white paper (spy tools do this for you)
    2. Be aware that objects have weird relations sometimes
  2. Walk iteratively  thru the hierarchy from top down (or from leafs up) to childs from left to right till object is found based on a property value
  3. Many "weird" objects that do not play by the rules of automation or bad developers not naming their objects for accessibility

 

Some explanation

  • findall creates a list and flattens the hierarchy to an arraylist but is slow (certainly with thousands of html elements)
  • findone is fast but complex as you have to create property conditions
  • walkers are nice to iterate up/down/left/right to find elements that are close to each other
  • eventhandlers are very powerfull but for most seem to be complex to understand
  • uiawrappers UDF abstracted a way to be more flexible at cost of speed
    • index/indexrelative
    • regular expressions
    • string syntax similar (but different) to AutoIt

 

 

Share this post


Link to post
Share on other sites

Hi @junkew

Thanks for the overview.  Some of the steps are starting to fall in into place.  I am working on a project (described in a post - 'Retrieve items from combo box with FindAll()') and need to try a different approach.  The goal is finding a combo box located on a web page and getting the contents with FindAll().  The problem is that SimpleSpy and UIASpy don't show the combo box most of the time.  Sometimes it will appear in Inspect. (I've tried all of the On/Off iterations of Chrome://accessibility I can think of) I'm going to start with treewalker.  I first need to do some reading and experimenting.  Will treewalker find  elements that are not picked up by spy software?

Thanks

Share this post


Link to post
Share on other sites

The issue you observe can be explained that objects are on top of each other technically. Inspect.exe will tell you true hierarchy. Treewalkers will find the same. If you spy html in chrome you can see based on highlighted area if accessibility is on or off.  If it really is not working you can spy browsers thru addressbar by executing small javascript pieces. 

Type in addressbar copy paste will not work as it strips javascript away. Be aware to lookup correct case sensitive syntax.

javascript:alert(document.body.innertext) 

 

Share this post


Link to post
Share on other sites

@junkew I've found the contents of the combo box I  was looking for in the web page html:

<select name="myposition_length" aria-controls="myposition" class="">
    <option value="10">10</option>
    <option value="15">15</option>
    <option value="30">30</option>
    <option value="-1">All</option>
</select>

My knowledge about web page information consists of zero but I'm guessing that 'name="myposition_length"' is what I'm looking for with treewalker.  Is that the right direction?  Like I mentioned before - I've got some serious research to do before I can ask intelligent questions.

Thanks again @junkew

Share this post


Link to post
Share on other sites

Hard to say there are many different webpage constructions. Do you see it on the accessibility page of chrome? What is highlighted when you check with simplespy? To use uiautomation you should see it in inspect.exe in the tree and be able to highlight it. If that all does not work the addressbar javascript is the only possibility to get full access to full html dom tree.

Share this post


Link to post
Share on other sites

Accessibility Tree:

2140419567_ComboBoxAccessibilityTree.png.0e5b55e93646a01106fb50a3fee26cd8.png

SimpleSpy output:

https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/?do=findComment&comment=1156373 
At least we have an element title: [My Trades | Webstats] class: [Chrome_RenderWidgetHostHWND]

Having the following values for all properties: 
Title is: <My Trades | Webstats>    Class   := <Chrome_RenderWidgetHostHWND>    controltype:= <UIA_DocumentControlTypeId>   ,<50030>    , (0000C36E)    2923;-687;94;93
*** Parent Information top down ***
0: Title is: <> Class   := <Chrome_WidgetWin_1> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    2923;-687;94;93
"Title:=;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1"" 


;~ *** Standard code maintainable ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

_UIA_setVar("oP1","Title:=;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1")   ;

_UIA_setVar("MyTrades|Webstats.mainwindow","title:=My Trades | Webstats;classname:=Chrome_RenderWidgetHostHWND")

;~ Actions split away from logical/technical definition above can come from configfiles 

;~_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")

_UIA_action("MyTrades|Webstats.mainwindow","setfocus")


;~ *** Standard code Flexible***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP0=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1", $treescope_children)  
_UIA_Action($oP0,"setfocus")
_UIA_setVar("MyTrades|Webstats.mainwindow","title:=My Trades | Webstats;classname:=Chrome_RenderWidgetHostHWND")
_UIA_action("MyTrades|Webstats.mainwindow","setfocus")


*** Detailed properties of the highlighted element ***
UIA_title:= <My Trades | Webstats>
UIA_text:= <My Trades | Webstats>
UIA_regexptitle:= <My Trades | Webstats>
UIA_class:= <Chrome_RenderWidgetHostHWND>
UIA_regexpclass:= <Chrome_RenderWidgetHostHWND>
UIA_iaccessiblevalue:= <https://app.journalytix.me/report>
UIA_iaccessiblechildId:= <0>
UIA_id:= <-1317983088>
UIA_handle:= <593196>
UIA_RuntimeId:= <42;593196;4;-34785>
UIA_BoundingRectangle:= <2923;-687;94;93>
; Main:Microsoft: MSAA Proxy (IAccessible2) (unmanaged:UIAutomationCore.DLL)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>
UIA_OptimizeForVisualContent:= <False>
UIA_IsObjectModelPatternAvailable:= <False>
UIA_AnnotationAnnotationTypeId:= <60000>
UIA_IsAnnotationPatternAvailable:= <False>
UIA_IsTextPattern2Available:= <True>
UIA_StylesStyleId:= <0>
UIA_StylesFillColor:= <0>
UIA_StylesFillPatternColor:= <0>
UIA_IsStylesPatternAvailable:= <False>
UIA_IsSpreadsheetPatternAvailable:= <False>
UIA_IsSpreadsheetItemPatternAvailable:= <False>
UIA_Transform2CanZoom:= <False>
UIA_IsTransformPattern2Available:= <False>
UIA_LiveSetting:= <0>
UIA_IsTextChildPatternAvailable:= <False>
UIA_IsDragPatternAvailable:= <False>
UIA_DragIsGrabbed:= <False>
UIA_IsDropTargetPatternAvailable:= <False>
UIA_Transform2ZoomLevel:= <1>
UIA_Transform2ZoomMinimum:= <1>
UIA_Transform2ZoomMaximum:= <1>
UIA_IsTextEditPatternAvailable:= <False>
UIA_IsPeripheral:= <False>
UIA_IsCustomNavigationPatternAvailable:= <False>
UIA_PositionInSet:= <0>
UIA_SizeOfSet:= <0>
UIA_Level:= <0>
UIA_LandmarkType:= <0>
UIA_FillType:= <0>
UIA_VisualEffects:= <0>
UIA_IsSelectionPattern2Available:= <False>
UIA_Selection2ItemCount:= <0>
UIA_HeadingLevel:= <80050>
UIA_IsDialog:= <False>

Highlight with Simplespy:

103326599_ScreenShotofMyTradesComboBox.thumb.jpg.8fddab6c498ec3318f8444cb3706c040.jpg

When I enter 'javascript:alert(document.body.innertext) ' into the address bar it just brings up a google search for "javascript:alert(document.body.innertext) ".  I'm misunderstanding  what I'm supposed to do with that action I think.  Inspect does show the combo box and it's contents in the tree.  

Thanks for all the effort.  

Share this post


Link to post
Share on other sites

Seems with simplespy accessibility is turned off.

As inspect is seeing it no need for javascript as thats far more difficult.

It does not make difference findall or a treewalker. Do a findall with only one chrome tab open and print all objects and property name. Most likely simplespy is working better when inspect is running. Somehow chrome thinks accessibility is off. You can start chrome with cmdline parameters to make sure accessibility is on.

Open on tab 1 your html page and on ab 2 accessibility turned on then back to tab 1 and check with simplespy.

Share this post


Link to post
Share on other sites

This is what the accessibility page shows when started with cmdline parameters:

(I checked the Internal box)

166637935_AccessibilityScreenShot.thumb.png.d8504efa80509d889e0983fdb3113aed.png

Screen shot of Inspect:651337338_InspectDisplay.thumb.png.44c834ce116712210915547493c84f2e.png

SimpleSpy out put is same:

https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/?do=findComment&comment=1156373 
At least we have an element title: [] class: [Chrome_RenderWidgetHostHWND]

Having the following values for all properties: 
Title is: <>    Class   := <Chrome_RenderWidgetHostHWND>    controltype:= <UIA_DocumentControlTypeId>   ,<50030>    , (0000C36E)    603;-602;94;93
*** Parent Information top down ***
0: Title is: <> Class   := <Chrome_WidgetWin_1> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    603;-602;94;93
"Title:=;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1"" 


;~ *** Standard code maintainable ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

_UIA_setVar("oP1","Title:=;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1")   ;

_UIA_setVar(".mainwindow","title:=;classname:=Chrome_RenderWidgetHostHWND")

;~ Actions split away from logical/technical definition above can come from configfiles 

;~_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")

_UIA_action(".mainwindow","setfocus")


;~ *** Standard code Flexible***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP0=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Chrome_WidgetWin_1", $treescope_children)  
_UIA_Action($oP0,"setfocus")
_UIA_setVar(".mainwindow","title:=;classname:=Chrome_RenderWidgetHostHWND")
_UIA_action(".mainwindow","setfocus")

Thank you so much for taking the time to look at this @junkew.  Rather than wasting more of your time, let me make some attempts at findall and treewalker.  Thanks

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By rmckay
      I'm trying to understand the use of TreeWalker and DllCall()s.  My ultimate goal is to use TreeWalker to list all children of webpages.  I've been working through the files for UIASpy to understand the logic.  After a weeks worth of searching for examples I'm still stuck on the reason for the repeated use of DllCalls in most of the functions.  Here is an example - the function 'UIASpy_CheckWindows()' (located in UIASpy_Elements.au3) is called from file UIASpy_Gui.au3.  In the function the following DllCall is used:
      DllCall( "user32.dll", "lresult", "SendMessageW", "hwnd", $hTV, "uint", $TVM_GETITEMW, "wparam", 0, "struct*", $tItem ) I understand that the function 'SendMessageW' in 'user32.dll' sends a message to the window $hTV.  The message is '$TVM_GETNEXTITEM' and '$tItem' is a struct with additional information - Microsoft Doc -https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessagew.  The window $hTV is created in UIASpy_Gui.au3 and that's where I get lost.  Is there code in UIASpy_Gui.au3 that handles this message?  I don't know what to look for.  This procedure - Function called that contains DllCall (SendMessage) is repeatedly used.  Thanks in advance.
    • By rmckay
      Hello,
      I'm trying to set a value in a combo box on a Chrome web page.  I've checked that the Chrome://accessibility is on and have checked to see that it's working with one of @LarsJ's scripts.  I've been able to locate the combo box and expand it.  I have then tried to put the contents into an element array.  When I check to see if the array is created there is no error.  When I check the size of the array with   '$oUIElementArray1.Length($iLength1)' the length is zero.  I then tried to set the value in the combo box with .SetValue().  No luck.  Next I tried to get the combo box items with '$oSelectionPattern1.GetCurrentSelection($pElementArray*)'.  My assumption is that the combo box items are put in an array - $pElementArray* though I couldn't get this to work in another program.  I've included the script and output.  This is my first attempt working with a website so that is likely where the problem is.  I've used all of the code except '$oSelectionPattern1' successfully in another script.
      #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include "C:\Users\Rod\Documents\AutoIt\Include\UIA_Constants.au3" ; Can be copied from UIASpy Includes folder #include "C:\Users\Rod\Documents\AutoIt\Include\CUIAutomation2WithDuplicatesRemoved.au3" ;~ #include "C:\Users\Rod\Documents\AutoIt\Jigsaw Open Journalytix\Jigsaw Open Journalytix 01.au3" Opt("MustDeclareVars", 1) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation8, $sIID_IUIAutomation5, $dtag_IUIAutomation5) If Not IsObj($oUIAutomation) Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oUIAutomation ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oUIAutomation OK" & @CRLF) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement($pDesktop) $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement8, $dtag_IUIAutomationElement8) If Not IsObj($oDesktop) Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oDesktop ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oDesktop OK" & @CRLF) ; --- Find window/control --- ConsoleWrite("--- Find window/control ---" & @CRLF) ; locate browser Local $pCondition0 $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "Chrome_WidgetWin_1", $pCondition0) If Not $pCondition0 Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $pCondition0 ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $pCondition0 OK" & @CRLF) Local $pPane1, $oPane1 $oDesktop.FindFirst($TreeScope_Descendants, $pCondition0, $pPane1) $oPane1 = ObjCreateInterface($pPane1, $sIID_IUIAutomationElement8, $dtag_IUIAutomationElement8) If Not IsObj($oPane1) Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oPane1 ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oPane1 OK" & @CRLF) ; --- Find combo box --- ConsoleWrite("--- Find combo box ---" & @CRLF) Local $pCondition1 $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ComboBoxControlTypeId, $pCondition1) If Not $pCondition1 Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $pCondition1 ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $pCondition1 OK" & @CRLF) Local $pComboBox1, $oComboBox1 $oPane1.FindFirst($TreeScope_Descendants, $pCondition1, $pComboBox1) $oComboBox1 = ObjCreateInterface($pComboBox1, $sIID_IUIAutomationElement8, $dtag_IUIAutomationElement8) If Not IsObj($oComboBox1) Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oComboBox1 ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oComboBox1 OK" & @CRLF) ; --- ExpandCollapse Pattern (action) Object --- ConsoleWrite("--- ExpandCollapse Pattern (action) Object ---" & @CRLF) Local $pExpandCollapsePattern1, $oExpandCollapsePattern1 $oComboBox1.GetCurrentPattern($UIA_ExpandCollapsePatternId, $pExpandCollapsePattern1) $oExpandCollapsePattern1 = ObjCreateInterface($pExpandCollapsePattern1, $sIID_IUIAutomationExpandCollapsePattern, $dtag_IUIAutomationExpandCollapsePattern) If Not IsObj($oExpandCollapsePattern1) Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oExpandCollapsePattern1 ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oExpandCollapsePattern1 OK" & @CRLF) ; --- ExpandCollapse Pattern (action) Methods --- ConsoleWrite("--- ExpandCollapse Pattern (action) Methods ---" & @CRLF) $oExpandCollapsePattern1.Expand() ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oExpandCollapsePattern1.Expand()" & @CRLF) Local $oUIElementArray1, $iLength1, $pElements ; $pElements is a pointer to an UI Automation element array Local $pTrueCondition $oUIAutomation.CreateTrueCondition($pTrueCondition) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oUIAutomation.CreateTrueCondition()" & @CRLF) If Not $pTrueCondition Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $pTrueCondition ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $pTrueCondition OK" & @CRLF) $oComboBox1.FindAll($TreeScope_Children, $pTrueCondition, $pElements) $oUIElementArray1 = ObjCreateInterface($pElements, $sIID_IUIAutomationElementArray, $dtag_IUIAutomationElementArray) If Not IsObj($oUIElementArray1) Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oUIElementArray1 ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oUIElementArray1 OK" & @CRLF) ; script stops here - apparently array is not created $oUIElementArray1.Length($iLength1) If Not $iLength1 Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $iLength1 = 0 ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $iLength1 = " & $iLength1 & @CRLF) #cs============================================================================= Display array #ce============================================================================= Local $pElement1, $oElement1, $sValue1 For $i = 0 To $iLength1 - 1 $oUIElementArray1.GetElement($i, $pElement1) $oElement1 = ObjCreateInterface($pElement1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $oElement1.GetCurrentPropertyValue($UIA_NamePropertyId, $sValue1) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $sValue" & $i & "= " & $sValue1 & @CRLF) Next ; --- LegacyIAccessible Pattern (action) Object --- ConsoleWrite("--- LegacyIAccessible Pattern (action) Object ---" & @CRLF) Local $pLegacyIAccessiblePattern1, $oLegacyIAccessiblePattern1 $oComboBox1.GetCurrentPattern($UIA_LegacyIAccessiblePatternId, $pLegacyIAccessiblePattern1) $oLegacyIAccessiblePattern1 = ObjCreateInterface($pLegacyIAccessiblePattern1, $sIID_IUIAutomationLegacyIAccessiblePattern, $dtag_IUIAutomationLegacyIAccessiblePattern) If Not IsObj($oLegacyIAccessiblePattern1) Then Return ConsoleWrite("$oLegacyIAccessiblePattern1 ERR" & @CRLF) ConsoleWrite("$oLegacyIAccessiblePattern1 OK" & @CRLF) ; --- LegacyIAccessible Pattern (action) Methods --- ; tried to set value into combobox but nothing happens ConsoleWrite("--- LegacyIAccessible Pattern (action) Methods ---" & @CRLF) Local $sShowEntriesCombobox = 'All' $oLegacyIAccessiblePattern1.SetValue($sShowEntriesCombobox) ConsoleWrite("$oLegacyIAccessiblePattern1.SetValue()" & @CRLF) ; --- Selection Pattern (action) Object --- ConsoleWrite("--- Selection Pattern (action) Object ---" & @CRLF) Local $pSelectionPattern1, $oSelectionPattern1 $oComboBox1.GetCurrentPattern($UIA_SelectionPatternId, $pSelectionPattern1) $oSelectionPattern1 = ObjCreateInterface($pSelectionPattern1, $sIID_IUIAutomationSelectionPattern, $dtag_IUIAutomationSelectionPattern) Sleep(1000) If Not IsObj($oSelectionPattern1) Then Return ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oSelectionPattern1 ERR" & @CRLF) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oSelectionPattern1 OK" & @CRLF) ; --- Selection Pattern (action) Methods --- ConsoleWrite("--- Selection Pattern (action) Methods ---" & @CRLF) $oSelectionPattern1.GetCurrentSelection($pElements) ConsoleWrite(':' & @ScriptLineNumber & ':' & " $oSelectionPattern1.GetCurrentSelection()" & @CRLF) EndFunc ;==>Example Console Output
      >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Rod\Documents\AutoIt\jigsaw Show Entries Code\JIgsa Show Entries Combobox - for Forum 02.au3" /UserParams +>15:31:00 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0 Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:2 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\Rod\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Rod\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) params:-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 from:C:\Program Files (x86)\AutoIt3 input:C:\Users\Rod\Documents\AutoIt\jigsaw Show Entries Code\JIgsa Show Entries Combobox - for Forum 02.au3 +>15:31:00 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Rod\Documents\AutoIt\jigsaw Show Entries Code\JIgsa Show Entries Combobox - for Forum 02.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop :18: $oUIAutomation OK :25: $oDesktop OK --- Find window/control --- :35: $pCondition0 OK :41: $oPane1 OK --- Find combo box --- :50: $pCondition1 OK :56: $oComboBox1 OK --- ExpandCollapse Pattern (action) Object --- :66: $oExpandCollapsePattern1 OK --- ExpandCollapse Pattern (action) Methods --- :73: $oExpandCollapsePattern1.Expand() :79: $oUIAutomation.CreateTrueCondition() :81: $pTrueCondition OK :88: $oUIElementArray1 OK :92: $iLength1 = 0 ERR +>15:31:00 AutoIt3.exe ended.rc:0 +>15:31:00 AutoIt3Wrapper Finished. >Exit code: 0 Time: 1.681 Thanks in advance
    • By rmckay
      I'm trying to set the slider in a window using RangeValuePattern.SetValue().  The window is used to set the start point for replaying market data in the app NinjaTrader 8. When using the Action window in Inspect.exe I can set a value and the slider responds.  When I run a script that selects the slider and uses .SetValue() with the same value the slider does not move.  I've tried giving the focus to the slider with no change in results.  
      #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code #AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code #include "C:\Users\Rod\Documents\AutoIt\Include\UIA_Constants.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_SafeArray.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Variant.au3" ; Can be copied from UIASpy Includes folder Opt("MustDeclareVars", 1) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation8, $sIID_IUIAutomation5, $dtag_IUIAutomation5) If Not IsObj($oUIAutomation) Then Return ConsoleWrite("$oUIAutomation ERR" & @CRLF) ConsoleWrite("$oUIAutomation OK" & @CRLF) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement($pDesktop) $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement8, $dtag_IUIAutomationElement8) If Not IsObj($oDesktop) Then Return ConsoleWrite("$oDesktop ERR" & @CRLF) ConsoleWrite("$oDesktop OK" & @CRLF) ; --- Find window/control --- ConsoleWrite("--- Find window/control ---" & @CRLF) Local $pCondition0 $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "Playback", $pCondition0) If Not $pCondition0 Then Return ConsoleWrite("$pCondition0 ERR" & @CRLF) ConsoleWrite("$pCondition0 OK" & @CRLF) Local $pWindow1, $oWindow1 $oDesktop.FindFirst($TreeScope_Descendants, $pCondition0, $pWindow1) $oWindow1 = ObjCreateInterface($pWindow1, $sIID_IUIAutomationElement8, $dtag_IUIAutomationElement8) If Not IsObj($oWindow1) Then Return ConsoleWrite("$oWindow1 ERR" & @CRLF) ConsoleWrite("$oWindow1 OK" & @CRLF) ; --- Find window/control --- ConsoleWrite("--- Find window/control ---" & @CRLF) Local $pCondition1 $oUIAutomation.CreatePropertyCondition($UIA_AutomationIdPropertyId, "slider", $pCondition1) If Not $pCondition1 Then Return ConsoleWrite("$pCondition1 ERR" & @CRLF) ConsoleWrite("$pCondition1 OK" & @CRLF) Local $pSlider1, $oSlider1 $oWindow1.FindFirst($TreeScope_Descendants, $pCondition1, $pSlider1) $oSlider1 = ObjCreateInterface($pSlider1, $sIID_IUIAutomationElement8, $dtag_IUIAutomationElement8) If Not IsObj($oSlider1) Then Return ConsoleWrite("$oSlider1 ERR" & @CRLF) ConsoleWrite("$oSlider1 OK" & @CRLF) ; --- RangeValue Pattern (action) Object --- ConsoleWrite("--- RangeValue Pattern (action) Object ---" & @CRLF) Local $pRangeValuePattern1, $oRangeValuePattern1 $oSlider1.GetCurrentPattern($UIA_RangeValuePatternId, $pRangeValuePattern1) $oRangeValuePattern1 = ObjCreateInterface($pRangeValuePattern1, $sIID_IUIAutomationRangeValuePattern, $dtag_IUIAutomationRangeValuePattern) If Not IsObj($oRangeValuePattern1) Then Return ConsoleWrite("$oRangeValuePattern1 ERR" & @CRLF) ConsoleWrite("$oRangeValuePattern1 OK" & @CRLF) ; --- RangeValue Pattern (action) Methods --- ConsoleWrite("--- RangeValue Pattern (action) Methods ---" & @CRLF) Local $iSetValue = 50000 $oRangeValuePattern1.SetValue($iSetValue) ConsoleWrite("$oRangeValuePattern1.SetValue()" & @CRLF) EndFunc ;==>Example Console Output
      >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Rod\Documents\AutoIt\NT8 PlayBack\NT8 PlayBack01.au3" /UserParams    
      +>10:39:16 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0   Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:2
      +>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Rod\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Rod\AppData\Local\AutoIt v3\SciTE 
      >Running AU3Check (3.3.14.5)  params:-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\Rod\Documents\AutoIt\NT8 PlayBack\NT8 PlayBack01.au3
      +>10:39:16 AU3Check ended.rc:0
      >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\Rod\Documents\AutoIt\NT8 PlayBack\NT8 PlayBack01.au3"    
      +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
      $oUIAutomation OK
      $oDesktop OK
      --- Find window/control ---
      $pCondition0 OK
      $oWindow1 OK
      --- Find window/control ---
      $pCondition1 OK
      $oSlider1 OK
      --- RangeValue Pattern (action) Object ---
      $oRangeValuePattern1 OK
      --- RangeValue Pattern (action) Methods ---
      $oRangeValuePattern1.SetValue()
      +>10:39:16 AutoIt3.exe ended.rc:0
      +>10:39:16 AutoIt3Wrapper Finished.
      >Exit code: 0    Time: 1.087
      I'm a noob with autoit and tried to attach screenshots to this post.  I have shots from UIASpy and Inspect.exe.  When I try to attach them I get an "Upload Failed" message.  They show results from the respective programs.  As an alternative I included the apps results with the slider selected.
      Inspect.exe:
      How found:    Selected from tree...
      Name:    ""
      ControlType:    UIA_SliderControlTypeId (0xC35F)
      LocalizedControlType:    "slider"
      BoundingRectangle:    {l:1579 t:531 r:1801 b:549}
      IsEnabled:    true
      IsOffscreen:    false
      IsKeyboardFocusable:    true
      HasKeyboardFocus:    false
      AcceleratorKey:    ""
      AccessKey:    ""
      ProcessId:    9928
      RuntimeId:    [7.26C8.279F814]
      AutomationId:    "slider"
      FrameworkId:    "WPF"
      ClassName:    "Slider"
      IsControlElement:    true
      IsContentElement:    true
      ProviderDescription:    "[pid:9928,providerId:0x0 Main(parent link):Unidentified Provider (managed:MS.Internal.Automation.ElementProxy, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)]"
      IsPassword:    false
      ItemStatus:    ""
      ItemType:    ""
      IsRequiredForForm:    false
      HelpText:    ""
      ClickablePoint:    {x:-2147483648 y:-2147483648}
      Orientation:    0
      LegacyIAccessible.ChildId:    0
      LegacyIAccessible.DefaultAction:    ""
      LegacyIAccessible.Description:    ""
      LegacyIAccessible.Help:    ""
      LegacyIAccessible.KeyboardShortcut:    ""
      LegacyIAccessible.Name:    ""
      LegacyIAccessible.Role:    slider (0x33)
      LegacyIAccessible.State:    focusable (0x100000)
      LegacyIAccessible.Value:    "0"
      RangeValue.IsReadOnly:    false
      RangeValue.LargeChange:    1.000000
      RangeValue.Maximum:    691200.000000
      RangeValue.Minimum:    0.000000
      RangeValue.SmallChange:    0.100000
      RangeValue.Value:    0.000000
      IsAnnotationPatternAvailable:    false
      IsDragPatternAvailable:    false
      IsDockPatternAvailable:    false
      IsDropTargetPatternAvailable:    false
      IsExpandCollapsePatternAvailable:    false
      IsGridItemPatternAvailable:    false
      IsGridPatternAvailable:    false
      IsInvokePatternAvailable:    false
      IsItemContainerPatternAvailable:    false
      IsLegacyIAccessiblePatternAvailable:    true
      IsMultipleViewPatternAvailable:    false
      IsObjectModelPatternAvailable:    false
      IsRangeValuePatternAvailable:    true
      IsScrollItemPatternAvailable:    false
      IsScrollPatternAvailable:    false
      IsSelectionItemPatternAvailable:    false
      IsSelectionPatternAvailable:    false
      IsSpreadsheetItemPatternAvailable:    false
      IsSpreadsheetPatternAvailable:    false
      IsStylesPatternAvailable:    false
      IsSynchronizedInputPatternAvailable:    true
      IsTableItemPatternAvailable:    false
      IsTablePatternAvailable:    false
      IsTextChildPatternAvailable:    false
      IsTextEditPatternAvailable:    false
      IsTextPatternAvailable:    false
      IsTextPattern2Available:    false
      IsTogglePatternAvailable:    false
      IsTransformPatternAvailable:    false
      IsTransform2PatternAvailable:    false
      IsValuePatternAvailable:    false
      IsVirtualizedItemPatternAvailable:    false
      IsWindowPatternAvailable:    false
      IsCustomNavigationPatternAvailable:    false
      IsSelectionPattern2Available:    false
      FirstChild:    "" thumb
      LastChild:    "" thumb
      Next:    "M0,3C0,3 0,4 0,4 0,4 3,4 3,4 3,4 3,3 3,3 3,3 4,3 4,3 4,3 4,4 4,4 4,4 7,4 7,4 7,4 7,3 7,3 7,3 6,3 6,3 6,3 6,2 6,2 6,2 5,2 5,2 5,
      Previous:    "" button
      Other Props:    Object has no additional properties
      Children:    "" thumb
      Ancestors:    "Playback" window
          "Desktop 1" pane
          [ No Parent ]
       
      UIASpy:
      Treeview Element                                    Slider: Slider
                                                          
      Element Properties (identification)                 
      $UIA_AutomationIdPropertyId                         slider
      $UIA_ClassNamePropertyId                            Slider
      $UIA_ControlTypePropertyId                          $UIA_SliderControlTypeId
                                                          
      Element Properties (session unique)                 
      $UIA_ProcessIdPropertyId                            9928
      $UIA_RuntimeIdPropertyId                            7,9928,41547796
                                                          
      Element Properties (information)                    
      $UIA_BoundingRectanglePropertyId                    l=1579,t=531,w=222,h=18
      $UIA_ClickablePointPropertyId                       -2147483648,-2147483648
      $UIA_FrameworkIdPropertyId                          WPF
      $UIA_HeadingLevelPropertyId                         80050
      $UIA_LocalizedControlTypePropertyId                 slider
      $UIA_OptimizeForVisualContentPropertyId             False
      $UIA_ProviderDescriptionPropertyId                  [pid:9928,providerId:0x0 Main(parent link):Unidentified Provider (managed:MS.Internal.Automation.ElementProxy, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)]
                                                          
      Element Properties (has/is info)                    
      $UIA_HasKeyboardFocusPropertyId                     False
      $UIA_IsContentElementPropertyId                     True
      $UIA_IsControlElementPropertyId                     True
      $UIA_IsDataValidForFormPropertyId                   False
      $UIA_IsDialogPropertyId                             False
      $UIA_IsEnabledPropertyId                            True
      $UIA_IsKeyboardFocusablePropertyId                  True
      $UIA_IsOffscreenPropertyId                          False
      $UIA_IsPasswordPropertyId                           False
      $UIA_IsPeripheralPropertyId                         False
      $UIA_IsRequiredForFormPropertyId                    False
                                                          
      Control Patterns (element actions)                  
      $UIA_IsLegacyIAccessiblePatternAvailablePropertyId  True (LegacyIAccessiblePattern)
      $UIA_IsRangeValuePatternAvailablePropertyId         True (RangeValuePattern)
      $UIA_IsSynchronizedInputPatternAvailablePropertyId  True (SynchronizedInputPattern)
                                                          
      Control Pattern Properties                          
      $UIA_LegacyIAccessibleChildIdPropertyId             0
      $UIA_LegacyIAccessibleDefaultActionPropertyId       
      $UIA_LegacyIAccessibleDescriptionPropertyId         
      $UIA_LegacyIAccessibleHelpPropertyId                
      $UIA_LegacyIAccessibleKeyboardShortcutPropertyId    
      $UIA_LegacyIAccessibleNamePropertyId                
      $UIA_LegacyIAccessibleRolePropertyId                51 = $ROLE_SYSTEM_SLIDER
      $UIA_LegacyIAccessibleStatePropertyId               1048576 = $STATE_SYSTEM_FOCUSABLE
      $UIA_LegacyIAccessibleValuePropertyId               0
      $UIA_RangeValueIsReadOnlyPropertyId                 False
      $UIA_RangeValueLargeChangePropertyId                1
      $UIA_RangeValueMaximumPropertyId                    691199.9999999
      $UIA_RangeValueMinimumPropertyId                    0
      $UIA_RangeValueSmallChangePropertyId                0.1
      $UIA_RangeValueValuePropertyId                      2.47032822920623e-319
                                                          
      Control Pattern Methods                             
      LegacyIAccessible Pattern Methods                   
                                                          DoDefaultAction()
                                                          Select(long)
                                                          SetValue(wstr)
                                                          GetIAccessible(idispatch*)
                                                          CurrentChildId(int*)
                                                          CurrentDefaultAction(bstr*)
                                                          CurrentDescription(bstr*)
                                                          CurrentHelp(bstr*)
                                                          CurrentKeyboardShortcut(bstr*)
                                                          CurrentName(bstr*)
                                                          CurrentRole(uint*)
                                                          CurrentState(uint*)
                                                          CurrentValue(bstr*)
                                                          GetCurrentSelection(ptr*)
      RangeValue Pattern Methods                          
                                                          SetValue(ushort)
                                                          CurrentIsReadOnly(long*)
                                                          CurrentMaximum(ushort*)
                                                          CurrentMinimum(ushort*)
                                                          CurrentLargeChange(ushort*)
                                                          CurrentSmallChange(ushort*)
                                                          CurrentValue(ushort*)
      SynchronizedInput Pattern Methods                   
                                                          StartListening(long)
                                                          Cancel()
                                                          
      Parents from Desktop                                Pane: Desktop 1
                                                          Window: Playback
                                                          
      Parent to child index                               
       
      In addition to this problem, I am unable to press the start button with an autoit script or by using inspect.exe=>Action=>Toggle() or inspect.exe=>Action=>DoDefaultAction().  I'll post that after solving the current problem.

       
    • By Earthshine
      So, I made this console app--using TreeWalkers of course to walk the UI Tree-- that starts at the root and looks for enabled, active controls--and in piping that to a file, I got this (edited, lots of controls in that list), above. LOL, so, those commands that are stored in memory are control elements! Sweet. this UIAutomation stuff is awesome. @junkew got me into this, blame his IUIAutomation kit. So there is this OLD vb OCX that is super ornery, but his kit can manipulate it, even if it is just SendKeys, So I must build a C# wrapper of my own... LOL this stuff is so cool. I have tried TestStack.White and MANY other wrappers, they seriously suck, no support either.
      I used canned Microsoft example code too for the most part. This is an extreme for me though, our modern stuff I can test easily enough, but I want my own kit to use to discover and poke around with. I like to use the IUIAutomation tool as a sanity check too, it's very useful.
       
    • By souldjer777
      Good Morning,
      I'm trying to use the code I had previously to select an item from a list. I believe I want to "setfocus". However, I'm getting and error and I believe it's my code. I don't know what Global Variables I should be using really - and I'm not sure if "setfocus" is the right function there at the bottom of my code... Thank you all as always!!!
      Local $hWindow = WinGetHandle("My Application") ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If Not IsObj($oUIAutomation) Then Return ConsoleWrite("UI Automation object ERR" & @CRLF) ConsoleWrite("UI Automation object OK" & @CRLF) ; Get UI Automation element from window handle Local $pWindow, $oWindow $oUIAutomation.ElementFromHandle($hWindow, $pWindow) $oWindow = ObjCreateInterface($pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oWindow) Then Return ConsoleWrite("Automation element from window ERR" & @CRLF) ConsoleWrite("Automation element from window OK" & @CRLF) ; Condition to find text "C:\Program Files (x86)" UIA_ListItemControlTypeId Local $pCondition, $pCondition1, $pCondition2 $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ListItemControlTypeId, $pCondition1) $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "C:\Program Files (x86)", $pCondition2) $oUIAutomation.CreateAndCondition($pCondition1, $pCondition2, $pCondition) If Not $pCondition Then Return ConsoleWrite("C:\Program Files (x86) condition ERR" & @CRLF) ConsoleWrite("C:\Program Files (x86) condition OK" & @CRLF) ; Find "C:\Program Files (x86)" List Item Local $pListItem, $oListItem $oWindow.FindFirst($TreeScope_Descendants, $pCondition, $pListItem) $oListItem = ObjCreateInterface($pListItem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oListItem) Then MsgBox(0, "", "Found List Item ERR") MsgBox(0, "", "Found List Item OK") ; Focus "C:\Program Files (x86)" ListItem Local $pFocus, $oFocus $oListItem.GetCurrentPattern($UIA_ListItemControlTypeId, $pFocus) $oFocus = ObjCreateInterface($pFocus, $sIID_IUIAutomationFocusChangedEventHandler, $dtagIUIAutomationFocusChangedEventHandler) If Not IsObj($oFocus) Then MsgBox(0, "", "Focus List Item ERR") MsgBox(0, "", "Focus List Item OK") $oFocus.setfocus() Sleep(2000) FYI - I was trying the "invoke" method and the list item was actually being double clicked on - which wont work - doing invoke would bring up a new window and all I wanted to do was select the item from the list.
×
×
  • Create New...