Jump to content

Unexpected result from UIAWrappers::_UIA_getObjectByFindAll


Recommended Posts

Dear All,
 
I want to control .NET application and I found that UIAWrappers is very userful.
But I have a problem with _UIA_getObjectByFindAll() function. Not sure if I use it correctly but _UIA_getObjectByFindAll return me wrong object. Below is source code that I use which is generated by simplespy

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

Local $oP2=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=<71028030> MAYBANK KIM ENG i2Trade Plus 3.0.16.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666", $treescope_children) 
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=Market Watch;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666", $treescope_children)  
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666", $treescope_children)    
_UIA_Action($oP0,"setfocus")
_UIA_setVar(".mainwindow","title:=;classname:=WindowsForms10.Window.8.app.0.202c666")
_UIA_action(".mainwindow","setfocus")

below is data of the target object which generated by simplespy

Mouse position is retrieved 637-484
At least we have an element [][WindowsForms10.Window.8.app.0.202c666]

Having the following values for all properties: 
Title is: <>    Class   := <WindowsForms10.Window.8.app.0.202c666>  controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    425;365;577;212
*** Parent Information top down ***
3: Title is: <Desktop>  Class   := <#32769> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    0;0;1366;768
"Title:=Desktop;controltype:=UIA_PaneControlTypeId;class:=#32769"   
2: Title is: <<71028030> MAYBANK KIM ENG i2Trade Plus 3.0.16.0> Class   := <WindowsForms10.Window.8.app.0.202c666>  controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    416;0;800;728
"Title:=<71028030> MAYBANK KIM ENG i2Trade Plus 3.0.16.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666" 
1: Title is: <Market Watch> Class   := <WindowsForms10.Window.8.app.0.202c666>  controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    425;117;577;460
"Title:=Market Watch;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666" 
0: Title is: <> Class   := <WindowsForms10.Window.8.app.0.202c666>  controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    425;338;577;239
"Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666"   


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

Local $oP2=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=<71028030> MAYBANK KIM ENG i2Trade Plus 3.0.16.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666", $treescope_children) 
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=Market Watch;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666", $treescope_children)  
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666", $treescope_children)    
_UIA_Action($oP0,"setfocus")
_UIA_setVar(".mainwindow","title:=;classname:=WindowsForms10.Window.8.app.0.202c666")
_UIA_action(".mainwindow","setfocus")


*** Detailed properties of the highlighted element ***
UIA_class:= <WindowsForms10.Window.8.app.0.202c666>
UIA_regexpclass:= <WindowsForms10.Window.8.app.0.202c666>
UIA_iaccessiblechildId:= <0>
UIA_id:= <intzaBBO>
UIA_handle:= <331012>
UIA_RuntimeId:= <42;331012>
UIA_BoundingRectangle:= <425;365;577;212>
UIA_ProcessId:= <25032>
UIA_ControlType:= <50033>
UIA_LocalizedControlType:= <pane>
UIA_HasKeyboardFocus:= <False>
UIA_IsKeyboardFocusable:= <True>
UIA_IsEnabled:= <True>
UIA_AutomationId:= <intzaBBO>
UIA_ClassName:= <WindowsForms10.Window.8.app.0.202c666>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <331012>
UIA_IsOffscreen:= <False>
UIA_Orientation:= <0>
UIA_FrameworkId:= <WinForm>
UIA_IsRequiredForForm:= <False>
UIA_IsDockPatternAvailable:= <False>
UIA_IsExpandCollapsePatternAvailable:= <False>
UIA_IsGridItemPatternAvailable:= <False>
UIA_IsGridPatternAvailable:= <False>
UIA_IsInvokePatternAvailable:= <False>
UIA_IsMultipleViewPatternAvailable:= <False>
UIA_IsRangeValuePatternAvailable:= <False>
UIA_IsScrollPatternAvailable:= <False>
UIA_IsScrollItemPatternAvailable:= <False>
UIA_IsSelectionItemPatternAvailable:= <False>
UIA_IsSelectionPatternAvailable:= <False>
UIA_IsTablePatternAvailable:= <False>
UIA_IsTableItemPatternAvailable:= <False>
UIA_IsTextPatternAvailable:= <False>
UIA_IsTogglePatternAvailable:= <False>
UIA_IsTransformPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <False>
UIA_IsWindowPatternAvailable:= <False>
UIA_ValueIsReadOnly:= <True>
UIA_RangeValueValue:= <0>
UIA_RangeValueIsReadOnly:= <True>
UIA_RangeValueMinimum:= <0>
UIA_RangeValueMaximum:= <0>
UIA_RangeValueLargeChange:= <0>
UIA_RangeValueSmallChange:= <0>
UIA_ScrollHorizontalScrollPercent:= <0>
UIA_ScrollHorizontalViewSize:= <100>
UIA_ScrollVerticalScrollPercent:= <0>
UIA_ScrollVerticalViewSize:= <100>
UIA_ScrollHorizontallyScrollable:= <False>
UIA_ScrollVerticallyScrollable:= <False>
UIA_SelectionCanSelectMultiple:= <False>
UIA_SelectionIsSelectionRequired:= <False>
UIA_GridRowCount:= <0>
UIA_GridColumnCount:= <0>
UIA_GridItemRow:= <0>
UIA_GridItemColumn:= <0>
UIA_GridItemRowSpan:= <1>
UIA_GridItemColumnSpan:= <1>
UIA_DockDockPosition:= <5>
UIA_ExpandCollapseExpandCollapseState:= <3>
UIA_MultipleViewCurrentView:= <0>
UIA_WindowCanMaximize:= <False>
UIA_WindowCanMinimize:= <False>
UIA_WindowWindowVisualState:= <0>
UIA_WindowWindowInteractionState:= <0>
UIA_WindowIsModal:= <False>
UIA_WindowIsTopmost:= <False>
UIA_SelectionItemIsSelected:= <False>
UIA_TableRowOrColumnMajor:= <2>
UIA_ToggleToggleState:= <2>
UIA_TransformCanMove:= <False>
UIA_TransformCanResize:= <False>
UIA_TransformCanRotate:= <False>
UIA_IsLegacyIAccessiblePatternAvailable:= <True>
UIA_LegacyIAccessibleChildId:= <0>
UIA_LegacyIAccessibleRole:= <10>
UIA_LegacyIAccessibleState:= <1048576>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:10116,hwnd:0x50D04 Main:Nested [pid:25032,hwnd:0x50D04 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

The object retruned by the function(wrong one)

Mouse position is retrieved 831-344
At least we have an element [Loading ...][WindowsForms10.Window.8.app.0.202c666]

Having the following values for all properties: 
Title is: <Loading ...> Class   := <WindowsForms10.Window.8.app.0.202c666>  controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    742;305;207;60
*** Parent Information top down ***
2: Title is: <Desktop>  Class   := <#32769> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    0;0;1366;768
"Title:=Desktop;controltype:=UIA_PaneControlTypeId;class:=#32769"   
1: Title is: <<71028030> MAYBANK KIM ENG i2Trade Plus 3.0.16.0> Class   := <WindowsForms10.Window.8.app.0.202c666>  controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    733;28;800;603
"Title:=<71028030> MAYBANK KIM ENG i2Trade Plus 3.0.16.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666" 
0: Title is: <Market Watch> Class   := <WindowsForms10.Window.8.app.0.202c666>  controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    742;145;577;412
"Title:=Market Watch;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666" 


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

Local $oP1=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=<71028030> MAYBANK KIM ENG i2Trade Plus 3.0.16.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666", $treescope_children) 
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Market Watch;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666", $treescope_children)  
_UIA_Action($oP0,"setfocus")
_UIA_setVar("Loading....mainwindow","title:=Loading ...;classname:=WindowsForms10.Window.8.app.0.202c666")
_UIA_action("Loading....mainwindow","setfocus")


*** Detailed properties of the highlighted element ***
UIA_title:= <Loading ...>
UIA_text:= <Loading ...>
UIA_regexptitle:= <Loading ...>
UIA_class:= <WindowsForms10.Window.8.app.0.202c666>
UIA_regexpclass:= <WindowsForms10.Window.8.app.0.202c666>
UIA_iaccessiblechildId:= <0>
UIA_id:= <intzaVolumeByBoard>
UIA_handle:= <200042>
UIA_RuntimeId:= <42;200042>
UIA_BoundingRectangle:= <742;305;207;60>
UIA_ProcessId:= <25032>
UIA_ControlType:= <50033>
UIA_LocalizedControlType:= <pane>
UIA_Name:= <Loading ...>
UIA_HasKeyboardFocus:= <True>
UIA_IsKeyboardFocusable:= <True>
UIA_IsEnabled:= <True>
UIA_AutomationId:= <intzaVolumeByBoard>
UIA_ClassName:= <WindowsForms10.Window.8.app.0.202c666>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <200042>
UIA_IsOffscreen:= <False>
UIA_Orientation:= <0>
UIA_FrameworkId:= <WinForm>
UIA_IsRequiredForForm:= <False>
UIA_IsDockPatternAvailable:= <False>
UIA_IsExpandCollapsePatternAvailable:= <False>
UIA_IsGridItemPatternAvailable:= <False>
UIA_IsGridPatternAvailable:= <False>
UIA_IsInvokePatternAvailable:= <False>
UIA_IsMultipleViewPatternAvailable:= <False>
UIA_IsRangeValuePatternAvailable:= <False>
UIA_IsScrollPatternAvailable:= <False>
UIA_IsScrollItemPatternAvailable:= <False>
UIA_IsSelectionItemPatternAvailable:= <False>
UIA_IsSelectionPatternAvailable:= <False>
UIA_IsTablePatternAvailable:= <False>
UIA_IsTableItemPatternAvailable:= <False>
UIA_IsTextPatternAvailable:= <False>
UIA_IsTogglePatternAvailable:= <False>
UIA_IsTransformPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <False>
UIA_IsWindowPatternAvailable:= <False>
UIA_ValueIsReadOnly:= <True>
UIA_RangeValueValue:= <0>
UIA_RangeValueIsReadOnly:= <True>
UIA_RangeValueMinimum:= <0>
UIA_RangeValueMaximum:= <0>
UIA_RangeValueLargeChange:= <0>
UIA_RangeValueSmallChange:= <0>
UIA_ScrollHorizontalScrollPercent:= <0>
UIA_ScrollHorizontalViewSize:= <100>
UIA_ScrollVerticalScrollPercent:= <0>
UIA_ScrollVerticalViewSize:= <100>
UIA_ScrollHorizontallyScrollable:= <False>
UIA_ScrollVerticallyScrollable:= <False>
UIA_SelectionCanSelectMultiple:= <False>
UIA_SelectionIsSelectionRequired:= <False>
UIA_GridRowCount:= <0>
UIA_GridColumnCount:= <0>
UIA_GridItemRow:= <0>
UIA_GridItemColumn:= <0>
UIA_GridItemRowSpan:= <1>
UIA_GridItemColumnSpan:= <1>
UIA_DockDockPosition:= <5>
UIA_ExpandCollapseExpandCollapseState:= <3>
UIA_MultipleViewCurrentView:= <0>
UIA_WindowCanMaximize:= <False>
UIA_WindowCanMinimize:= <False>
UIA_WindowWindowVisualState:= <0>
UIA_WindowWindowInteractionState:= <0>
UIA_WindowIsModal:= <False>
UIA_WindowIsTopmost:= <False>
UIA_SelectionItemIsSelected:= <False>
UIA_TableRowOrColumnMajor:= <2>
UIA_ToggleToggleState:= <2>
UIA_TransformCanMove:= <False>
UIA_TransformCanResize:= <False>
UIA_TransformCanRotate:= <False>
UIA_IsLegacyIAccessiblePatternAvailable:= <True>
UIA_LegacyIAccessibleChildId:= <0>
UIA_LegacyIAccessibleName:= <Loading ...>
UIA_LegacyIAccessibleRole:= <10>
UIA_LegacyIAccessibleState:= <1048580>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:12728,hwnd:0x30D6A Main:Nested [pid:25032,hwnd:0x30D6A Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

Notice that Title, controltype, class are the same but id is different. So I change the code to

Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666;id:=intzaBBO", $treescope_children)

But no luck. Can someone point me the correct way?

Thanks,

PS

Link to comment
Share on other sites

junkew,

I have done follow your comment by

1. Add instance:=1 or instance:=2 or instance:=3. But the focus object is the same

2. Add id:=intzaBBO as a property. Still no luck

3. indexafter property. Don't know what is the format value of this property. Anyway I have tried indexafter:=1 or indexafter:=2 But the focus object is the same

Here is my full code

AutoItSetOption("MustDeclareVars", 1)

Local $oP2=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=<71028030> MAYBANK KIM ENG i2Trade Plus 3.0.16.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666", $treescope_children)
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=Market Watch;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.202c666", $treescope_children)
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;classname:=WindowsForms10.Window.8.app.0.202c666", $treescope_children)

_UIA_Action($oP0,"setfocus")

Just apply the parameters you mentioned in the red line. Not sure if this is what you intend.

 
Link to comment
Share on other sites

sorry incorrect property.

This is what i referred to

const $cSearchButton="name:=Search.*; indexrelative:=3"

If you check with inspect.exe you have a tree and you can see what objects come after

So with above syntax it just finds an object with an easy identifiable property and indexrelative just skips then 3 objects further

Partly you can find out which objects there are with UIA_Dumpthemall function which dumps the tree to the logfile. Personally I prefer inspect.exe.

index and instance property have same behavior and gives back the n-th instance of an object with same properties

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...