Jump to content
junkew

IUIAutomation MS framework automate chrome, FF, IE, ....

Recommended Posts

Zein

Would the entire script be necessary for just a simple click?

If I know my automation ID and all I want is for that specific ID to be clicked, would it require more than just:

$oButton = _UIA_getFirstObjectOfElement($UIA_oDesktop, "automationid:=XYZButton", $TreeScope_Children)
        _UIA_Action($oButton,"click",1,1)

All this does is make a red outline appear over my taskbar, so I'm a bit unsure of what's wrong. 
 

Share this post


Link to post
Share on other sites
junkew

In general steps can be shorter then script simplespy gives if you skip parts of the ui hierarchy

You can play with $TreeScope_Subtree

"normal flow"

  1. Setfocus to your main window
  2. Find childobject under mainwindow
  3. Do your action on your childobject

So as taskbar highlights instead of your button most likely your automationid is wrong (or not unique)

 

 

 

 

Share this post


Link to post
Share on other sites
Zein

Is simplespy mandatory? I haven't tried using it.

I'm absolutely sure that my automation ID is correct and unique, given that using the row walker method it works just fine.

 

Share this post


Link to post
Share on other sites
junkew

simplespy output will definitely help if you are asking help in the forum. Now i can only guess what you are doing,

A reproducer script would help.

Simplespy gave below and works fine on my dutch system with notepad in taskbar (commented out $oP2 and $oP1 and search $oUIElement under $oP3)

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

Local $oP3=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Taakbalk;controltype:=UIA_PaneControlTypeId;class:=Shell_TrayWnd", $treescope_children)   
_UIA_Action($oP3,"setfocus")
;~ Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ReBarWindow32", $treescope_children) 
;~ _UIA_Action($oP2,"setfocus")
;~ Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=Actieve toepassingen;controltype:=UIA_PaneControlTypeId;class:=MSTaskSwWClass", $treescope_children)    
;~ _UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP3, "Title:=Actieve toepassingen;controltype:=UIA_ToolBarControlTypeId;class:=MSTaskListWClass", $treescope_children)  
_UIA_Action($oP0,"setfocus")
;~ First find the object in the parent before you can do something
;~$oUIElement=_UIA_getObjectByFindAll("Kladblok.mainwindow", "title:=Kladblok;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree)
Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=Kladblok;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree)
;~_UIA_action($oUIElement,"highlight")
_UIA_action($oUIElement,"click")

And this could work to (but much slower), you could leave out highlight its there just to show what happens (I assume you have highlighting on as thats the default in the wrappers)

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

Local $oUIElement=_UIA_getObjectByFindAll($UIA_oDesktop, "title:=Kladblok;ControlType:=UIA_ButtonControlTypeId", $treescope_subtree)
_UIA_action($oUIElement,"focus")
_UIA_action($oUIElement,"highlight")
_UIA_action($oUIElement,"click")

 

So most likely you try to click on a nonvisible element and your taskbar is hidden. Window/Object first needs to be visible and frequently needs to have focus (but that really differs per controltype)

Share this post


Link to post
Share on other sites
Zein

I haven't been able to get simplespy to work is the issue. 

My button is very clearly visible on a unique window, nothing about it is generic. Rowwalker accurately clicks what it has to, but I will try to get simplespy working to learn what I'm doing wrong with my earlier approach.

 

Share this post


Link to post
Share on other sites
junkew

First try simplespy.au3  and inspect.exe on calc.exe to see if all is available on your windows system.

Depending on ui hierarchy it could be that techically another transparent group element is over your button. So although human visible button tools see the top most window first.

Share this post


Link to post
Share on other sites
Zein

This is interesting.

I have a Tile-window appear in my app, and if I use simplespy to generate code that clicks buttons it works perfectly fine.

I also have an overall dashboard that contains multiple tiles in it, but using simplespy to generate the code to click a specific button makes it click on the corner of the window.

Share this post


Link to post
Share on other sites
traff

I have issues with properties containing a semicolon, as it is used to split multiple properties within the findAll method. Will it be possible to add an option to set the split character for multiple properties or to add an escape character to avoid splitting those properties?

e.g.

Func _UIA_normalizeExpression($sPropList)
    Local $asAllProperties ;~ All properties of the expression to match in a splitted form
    Local $iPropertyCount ;~ Number of properties given in the expression
    Local $asProperties2Match[1][4] ;~ All properties of the expression to match in a normalized form

    Local $i ;~ Just a looping integer
    Local $aKV ;~ Array key/value pair
    Local $iMatch ;~ Temp value to see if there is a match on that property
    Local $propName, $propValue
    Local $bSkipSpecialProperty ;~ Skips the specific special properties

    Local $UIA_oUIElement
    Local $UIA_pUIElement

    Local $index

;~  Split it first into multiple sections representing each property
    $asAllProperties = StringSplit($sPropList, $SPLIT_CHAR, 1)

 

Share this post


Link to post
Share on other sites
Viszna

I'd like to say hi
and i'm sorry my english :)
I started to do rehearsals with IUIAutomation -it is very very OK.
I succeed "gettext", "click", super works with calculator in Win10 :lmao: (Au3Info could not read window calculator) 
I practice on a free program Data Faktury Lite (free)
My problem is: read/write single cell in Grid or one whole row. Is it possible?
How to get the max number of rows and columns?

0question.jpg.5b0454a98051b1e8d897b74710e044a2.jpg

Au3info this object

>>>> Window <<<<
Title:  Data Faktury Lite wer. 4.2.1.0
Class:  WindowsForms10.Window.8.app.0.13965fa_r9_ad1
Position:   70, 94
Size:   1231, 616
Style:  0x16CF0000
ExStyle:    0x00050100
Handle: 0x0000000000290740

>>>> Control <<<<
Class:  WindowsForms10.Window.8.app.0.13965fa_r9_ad1
Instance:   8
ClassnameNN:    WindowsForms10.Window.8.app.0.13965fa_r9_ad18
Name:   Grid
Advanced (Class):   [NAME:Grid]
ID: 1771054
Text:   
Position:   222, 119
Size:   954, 408
ControlClick Coords:    473, 139
Style:  0x56010000
ExStyle:    0x00000000
Handle: 0x00000000001B062E

>>>> Mouse <<<<
Position:   773, 403
Cursor ID:  0
Color:  0xF0F0F0

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Przelewy
Noty
Zakupy
Kilometrówka
Sprzedaż
Kasa
Kontrahenci
Towary
Lista Kontrahentów
Wszyscy
Szukaj

CellGrid Simple UIA Spy

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: [DataGridView] class: [WindowsForms10.Window.8.app.0.13965fa_r9_ad1]

Having the following values for all properties: 
Title is: <DataGridView>    Class   := <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>   controltype:= <UIA_TableControlTypeId>  ,<50036>    , (0000C374)    229;179;954;408
*** Parent Information top down ***
4: Title is: <Data Faktury Lite wer. 4.2.1.0>   Class   := <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>   controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    -1;9;1231;616
"Title:=Data Faktury Lite wer. 4.2.1.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1""   
3: Title is: <Z dnia: > Class   := <WindowsForms10.MDICLIENT.app.0.13965fa_r9_ad1>  controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    133;60;1089;557
"Title:=Z dnia: ;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.MDICLIENT.app.0.13965fa_r9_ad1""  
2: Title is: <Lista Kontrahentów>  Class   := <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>   controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    158;110;1042;497
"Title:=Lista Kontrahentów;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1""  
1: Title is: <> Class   := <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>   controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    166;141;1026;458
"Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1""   
0: Title is: <> Class   := <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>   controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    221;141;971;458
"Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1""   


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

_UIA_setVar("oP1","Title:=Data Faktury Lite wer. 4.2.1.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1") ;Data Faktury Lite wer. 4.2.1.0
_UIA_setVar("oP2","Title:=Z dnia: ;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.MDICLIENT.app.0.13965fa_r9_ad1")    ;Z dnia: 
_UIA_setVar("oP3","Title:=Lista Kontrahentów;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1")    ;Lista Kontrahentów
_UIA_setVar("oP4","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1") ;
_UIA_setVar("oP5","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1") ;

_UIA_setVar("DataGridView.mainwindow","title:=DataGridView;classname:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1")

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

;~_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")
;~_UIA_Action("oP2","highlight")
_UIA_Action("oP2","setfocus")
;~_UIA_Action("oP3","highlight")
_UIA_Action("oP3","setfocus")
;~_UIA_Action("oP4","highlight")
_UIA_Action("oP4","setfocus")
;~_UIA_Action("oP5","highlight")
_UIA_Action("oP5","setfocus")

_UIA_action("DataGridView.mainwindow","setfocus")


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

Local $oP4=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Data Faktury Lite wer. 4.2.1.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1", $treescope_children)    
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=Z dnia: ;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.MDICLIENT.app.0.13965fa_r9_ad1", $treescope_children)    
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=Lista Kontrahentów;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1", $treescope_children)    
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1", $treescope_children) 
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1", $treescope_children) 
_UIA_Action($oP0,"setfocus")
_UIA_setVar("DataGridView.mainwindow","title:=DataGridView;classname:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1")
_UIA_action("DataGridView.mainwindow","setfocus")


*** Detailed properties of the highlighted element ***
UIA_title:= <DataGridView>
UIA_text:= <DataGridView>
UIA_regexptitle:= <DataGridView>
UIA_class:= <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>
UIA_regexpclass:= <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>
UIA_iaccessiblechildId:= <0>
UIA_id:= <Grid>
UIA_handle:= <1771054>
UIA_RuntimeId:= <42;1771054>
UIA_BoundingRectangle:= <229;179;954;408>
; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

First cell in rows1 (text: ZET)

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: [Kod Wiersz 1] class: []

Having the following values for all properties: 
Title is: <Kod Wiersz 1>    Class   := <>   controltype:= <UIA_DataItemControlTypeId>   ,<50029>    , (0000C36D)    230;224;100;22
*** Parent Information top down ***
6: Title is: <Data Faktury Lite wer. 4.2.1.0>   Class   := <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>   controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    -1;9;1231;616
"Title:=Data Faktury Lite wer. 4.2.1.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1""   
5: Title is: <Z dnia: > Class   := <WindowsForms10.MDICLIENT.app.0.13965fa_r9_ad1>  controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    133;60;1089;557
"Title:=Z dnia: ;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.MDICLIENT.app.0.13965fa_r9_ad1""  
4: Title is: <Lista Kontrahentów>  Class   := <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>   controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    158;110;1042;497
"Title:=Lista Kontrahentów;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1""  
3: Title is: <> Class   := <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>   controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    166;141;1026;458
"Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1""   
2: Title is: <> Class   := <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>   controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    221;141;971;458
"Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1""   
1: Title is: <DataGridView> Class   := <WindowsForms10.Window.8.app.0.13965fa_r9_ad1>   controltype:= <UIA_TableControlTypeId>  ,<50036>    , (0000C374)    229;179;954;408
"Title:=DataGridView;controltype:=UIA_TableControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1""  
0: Title is: <Wiersz 1> Class   := <>   controltype:= <UIA_CustomControlTypeId> ,<50025>    , (0000C369)    230;224;953;22
"Title:=Wiersz 1;controltype:=UIA_CustomControlTypeId;class:="" 


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

_UIA_setVar("oP1","Title:=Data Faktury Lite wer. 4.2.1.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1") ;Data Faktury Lite wer. 4.2.1.0
_UIA_setVar("oP2","Title:=Z dnia: ;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.MDICLIENT.app.0.13965fa_r9_ad1")    ;Z dnia: 
_UIA_setVar("oP3","Title:=Lista Kontrahentów;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1")    ;Lista Kontrahentów
_UIA_setVar("oP4","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1") ;
_UIA_setVar("oP5","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1") ;
_UIA_setVar("oP6","Title:=DataGridView;controltype:=UIA_TableControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1")    ;DataGridView
_UIA_setVar("oP7","Title:=Wiersz 1;controltype:=UIA_CustomControlTypeId;class:=")   ;Wiersz 1

;~ $oUIElement=_UIA_getObjectByFindAll("KodWiersz1.mainwindow", "title:=Kod Wiersz 1;ControlType:=UIA_DataItemControlTypeId", $treescope_subtree)
_UIA_setVar("oUIElement","Title:=Kod Wiersz 1;controltype:=UIA_DataItemControlTypeId;class:=") ;ControlType:=UIA_DataItemControlTypeId;classname:=")

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

;~_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")
;~_UIA_Action("oP2","highlight")
_UIA_Action("oP2","setfocus")
;~_UIA_Action("oP3","highlight")
_UIA_Action("oP3","setfocus")
;~_UIA_Action("oP4","highlight")
_UIA_Action("oP4","setfocus")
;~_UIA_Action("oP5","highlight")
_UIA_Action("oP5","setfocus")
;~_UIA_Action("oP6","highlight")
_UIA_Action("oP6","setfocus")
;~_UIA_Action("oP7","highlight")
_UIA_Action("oP7","setfocus")

_UIA_action("oUIElement","highlight")
;~_UIA_action("oUIElement","click")


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

Local $oP6=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Data Faktury Lite wer. 4.2.1.0;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1", $treescope_children)    
_UIA_Action($oP6,"setfocus")
Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=Z dnia: ;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.MDICLIENT.app.0.13965fa_r9_ad1", $treescope_children)    
_UIA_Action($oP5,"setfocus")
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=Lista Kontrahentów;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1", $treescope_children)    
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1", $treescope_children) 
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1", $treescope_children) 
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=DataGridView;controltype:=UIA_TableControlTypeId;class:=WindowsForms10.Window.8.app.0.13965fa_r9_ad1", $treescope_children)    
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Wiersz 1;controltype:=UIA_CustomControlTypeId;class:=", $treescope_children)   
;~ First find the object in the parent before you can do something
;~$oUIElement=_UIA_getObjectByFindAll("KodWiersz1.mainwindow", "title:=Kod Wiersz 1;ControlType:=UIA_DataItemControlTypeId", $treescope_subtree)
Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=Kod Wiersz 1;ControlType:=UIA_DataItemControlTypeId", $treescope_subtree)
;~_UIA_action($oUIElement,"highlight")
_UIA_action($oUIElement,"click")


*** Detailed properties of the highlighted element ***
UIA_title:= <Kod Wiersz 1>
UIA_text:= <Kod Wiersz 1>
UIA_regexptitle:= <Kod Wiersz 1>
UIA_iaccessiblevalue:= <ZET>
UIA_iaccessiblechildId:= <0>
UIA_handle:= <0>
UIA_BoundingRectangle:= <230;224;100;22>
 

The whole app in inspect -screen tree

inspect_tree_application.jpg.4f3112f94bbeec3928f3d78b30693133.jpg

And hierarchy from the main window Data Faktury to the cell (text "ZET") (7 elements)

How found:  Selected from tree...
Name:   "Data Faktury Lite wer. 4.2.1.0"
ControlType:    UIA_WindowControlTypeId (0xC370)
LocalizedControlType:   "okno"
BoundingRectangle:  {l:-1 t:9 r:1230 b:625}
IsEnabled:  true
IsOffscreen:    false
IsKeyboardFocusable:    true
HasKeyboardFocus:   false
AccessKey:  ""
ProcessId:  5572
RuntimeId:  [2A.290740]
AutomationId:   "MDIGlowna"
FrameworkId:    "WinForm"
ClassName:  "WindowsForms10.Window.8.app.0.13965fa_r9_ad1"
NativeWindowHandle: 0x290740
ProviderDescription:    "[pid:9572,providerId:0x290740 Main:Nested [pid:5572,providerId:0x290740 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
HelpText:   ""
IsDialog:   [Not supported]
LegacyIAccessible.ChildId:  0
LegacyIAccessible.DefaultAction:    ""
LegacyIAccessible.Description:  ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "Data Faktury Lite wer. 4.2.1.0"
LegacyIAccessible.Role: klient (0xA)
LegacyIAccessible.State:    z możliwością przeniesienia fokusu (0x100000)
LegacyIAccessible.Value:    ""
Transform.CanMove:  true
Transform.CanResize:    true
Transform.CanRotate:    false
Window.CanMaximize: true
Window.CanMinimize: true
Window.IsModal: false
Window.IsTopmost:   false
Window.WindowInteractionState:  ReadyForUserInteraction (2)
Window.WindowVisualState:   Normal (0)
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:   false
IsScrollItemPatternAvailable:   false
IsScrollPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    false
IsSpreadsheetItemPatternAvailable:  false
IsSpreadsheetPatternAvailable:  false
IsStylesPatternAvailable:   false
IsSynchronizedInputPatternAvailable:    false
IsTableItemPatternAvailable:    false
IsTablePatternAvailable:    false
IsTextChildPatternAvailable:    false
IsTextEditPatternAvailable: false
IsTextPatternAvailable: false
IsTextPattern2Available:    false
IsTogglePatternAvailable:   false
IsTransformPatternAvailable:    true
IsTransform2PatternAvailable:   false
IsValuePatternAvailable:    false
IsVirtualizedItemPatternAvailable:  false
IsWindowPatternAvailable:   true
IsCustomNavigationPatternAvailable: false
IsSelectionPattern2Available:   false
FirstChild: "Dostępna jest nowa wersja 1.5.0.0" okienko
LastChild:  "Aplikacja" pasek menu
Next:   "Program Manager" okienko
Previous:   "Grid" okno
Other Props:    Object has no additional properties
Children:   "Dostępna jest nowa wersja 1.5.0.0" okienko
    "Z dnia: " okienko
    (null) pasek tytułu
    "Aplikacja" pasek menu
Ancestors:  "Pulpit 1" okienko
    [ No Parent ]
==========================================================================
==========================================================================
How found:  Selected from tree...
Name:   "Z dnia: "
ControlType:    UIA_PaneControlTypeId (0xC371)
LocalizedControlType:   "okienko"
BoundingRectangle:  {l:133 t:60 r:1222 b:617}
IsEnabled:  true
IsOffscreen:    false
IsKeyboardFocusable:    true
HasKeyboardFocus:   false
AccessKey:  ""
ProcessId:  5572
RuntimeId:  [2A.110998]
AutomationId:   "1116568"
FrameworkId:    "WinForm"
ClassName:  "WindowsForms10.MDICLIENT.app.0.13965fa_r9_ad1"
NativeWindowHandle: 0x110998
ProviderDescription:    "[pid:9572,providerId:0x110998 Main:Nested [pid:5572,providerId:0x110998 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
HelpText:   ""
IsDialog:   [Not supported]
LegacyIAccessible.ChildId:  0
LegacyIAccessible.DefaultAction:    ""
LegacyIAccessible.Description:  ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "Z dnia: "
LegacyIAccessible.Role: klient (0xA)
LegacyIAccessible.State:    z możliwością przeniesienia fokusu (0x100000)
LegacyIAccessible.Value:    ""
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:   false
IsScrollItemPatternAvailable:   false
IsScrollPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    false
IsSpreadsheetItemPatternAvailable:  false
IsSpreadsheetPatternAvailable:  false
IsStylesPatternAvailable:   false
IsSynchronizedInputPatternAvailable:    false
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: "Lista Kontrahentów" okno
LastChild:  "Lista Kontrahentów" okno
Next:   (null) pasek tytułu
Previous:   "Dostępna jest nowa wersja 1.5.0.0" okienko
Other Props:    Object has no additional properties
Children:   "Lista Kontrahentów" okno
Ancestors:  "Data Faktury Lite wer. 4.2.1.0" okno
    "Pulpit 1" okienko
    [ No Parent ]

==========================================================================
==========================================================================
How found:  Selected from tree...
Name:   "Lista Kontrahentów"
ControlType:    UIA_WindowControlTypeId (0xC370)
LocalizedControlType:   "okno"
BoundingRectangle:  {l:158 t:110 r:1200 b:607}
IsEnabled:  true
IsOffscreen:    false
IsKeyboardFocusable:    true
HasKeyboardFocus:   false
AccessKey:  ""
ProcessId:  5572
RuntimeId:  [2A.2308EA]
AutomationId:   "fListKontrahentow"
FrameworkId:    "WinForm"
ClassName:  "WindowsForms10.Window.8.app.0.13965fa_r9_ad1"
NativeWindowHandle: 0x2308EA
ProviderDescription:    "[pid:9572,providerId:0x2308EA Main:Nested [pid:5572,providerId:0x2308EA Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
HelpText:   ""
IsDialog:   [Not supported]
LegacyIAccessible.ChildId:  0
LegacyIAccessible.DefaultAction:    ""
LegacyIAccessible.Description:  ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "Lista Kontrahentów"
LegacyIAccessible.Role: klient (0xA)
LegacyIAccessible.State:    z możliwością przeniesienia fokusu (0x100000)
LegacyIAccessible.Value:    ""
Transform.CanMove:  true
Transform.CanResize:    true
Transform.CanRotate:    false
Window.CanMaximize: true
Window.CanMinimize: true
Window.IsModal: false
Window.IsTopmost:   false
Window.WindowInteractionState:  ReadyForUserInteraction (2)
Window.WindowVisualState:   Normal (0)
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:   false
IsScrollItemPatternAvailable:   false
IsScrollPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    false
IsSpreadsheetItemPatternAvailable:  false
IsSpreadsheetPatternAvailable:  false
IsStylesPatternAvailable:   false
IsSynchronizedInputPatternAvailable:    false
IsTableItemPatternAvailable:    false
IsTablePatternAvailable:    false
IsTextChildPatternAvailable:    false
IsTextEditPatternAvailable: false
IsTextPatternAvailable: false
IsTextPattern2Available:    false
IsTogglePatternAvailable:   false
IsTransformPatternAvailable:    true
IsTransform2PatternAvailable:   false
IsValuePatternAvailable:    false
IsVirtualizedItemPatternAvailable:  false
IsWindowPatternAvailable:   true
IsCustomNavigationPatternAvailable: false
IsSelectionPattern2Available:   false
FirstChild: "" okienko
LastChild:  (null) pasek tytułu
Next:   [null]
Previous:   [null]
Other Props:    Object has no additional properties
Children:   "" okienko
    (null) pasek tytułu
Ancestors:  "Z dnia: " okienko
    "Data Faktury Lite wer. 4.2.1.0" okno
    "Pulpit 1" okienko
    [ No Parent ]

==========================================================================
==========================================================================
How found:  Selected from tree...
Name:   ""
ControlType:    UIA_PaneControlTypeId (0xC371)
LocalizedControlType:   "okienko"
BoundingRectangle:  {l:166 t:141 r:1192 b:599}
IsEnabled:  true
IsOffscreen:    false
IsKeyboardFocusable:    true
HasKeyboardFocus:   false
AccessKey:  ""
ProcessId:  5572
RuntimeId:  [2A.280818]
AutomationId:   "spliter"
FrameworkId:    "WinForm"
ClassName:  "WindowsForms10.Window.8.app.0.13965fa_r9_ad1"
NativeWindowHandle: 0x280818
ProviderDescription:    "[pid:9572,providerId:0x280818 Main:Nested [pid:5572,providerId:0x280818 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
HelpText:   ""
IsDialog:   [Not supported]
LegacyIAccessible.ChildId:  0
LegacyIAccessible.DefaultAction:    ""
LegacyIAccessible.Description:  ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: ""
LegacyIAccessible.Role: klient (0xA)
LegacyIAccessible.State:    z możliwością przeniesienia fokusu (0x100000)
LegacyIAccessible.Value:    ""
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:   false
IsScrollItemPatternAvailable:   false
IsScrollPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    false
IsSpreadsheetItemPatternAvailable:  false
IsSpreadsheetPatternAvailable:  false
IsStylesPatternAvailable:   false
IsSynchronizedInputPatternAvailable:    false
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: "" okienko
LastChild:  "" okienko
Next:   (null) pasek tytułu
Previous:   [null]
Other Props:    Object has no additional properties
Children:   "" okienko
    "" okienko
Ancestors:  "Lista Kontrahentów" okno
    "Z dnia: " okienko
    "Data Faktury Lite wer. 4.2.1.0" okno
    "Pulpit 1" okienko
    [ No Parent ]

==========================================================================
==========================================================================
How found:  Selected from tree...
Name:   "DataGridView"
ControlType:    UIA_TableControlTypeId (0xC374)
LocalizedControlType:   "tabela"
BoundingRectangle:  {l:229 t:179 r:1183 b:587}
IsEnabled:  true
IsOffscreen:    false
IsKeyboardFocusable:    true
HasKeyboardFocus:   false
AccessKey:  ""
ProcessId:  5572
RuntimeId:  [2A.1B062E]
AutomationId:   "Grid"
FrameworkId:    "WinForm"
ClassName:  "WindowsForms10.Window.8.app.0.13965fa_r9_ad1"
NativeWindowHandle: 0x1B062E
ProviderDescription:    "[pid:9572,providerId:0x1B062E Main:Nested [pid:5572,providerId:0x1B062E Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
HelpText:   ""
IsDialog:   [Not supported]
LegacyIAccessible.ChildId:  0
LegacyIAccessible.DefaultAction:    ""
LegacyIAccessible.Description:  ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "DataGridView"
LegacyIAccessible.Role: tabela (0x18)
LegacyIAccessible.State:    z możliwością przeniesienia fokusu (0x100000)
LegacyIAccessible.Value:    ""
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:   false
IsScrollItemPatternAvailable:   false
IsScrollPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    false
IsSpreadsheetItemPatternAvailable:  false
IsSpreadsheetPatternAvailable:  false
IsStylesPatternAvailable:   false
IsSynchronizedInputPatternAvailable:    false
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: "Górny wiersz" 
LastChild:  "Wiersz 2" 
Next:   "Szukaj" tekst
Previous:   "Szukaj" przycisk
Other Props:    Object has no additional properties
Children:   "Górny wiersz" 
    "Wiersz 0" 
    "Wiersz 1" 
    "Wiersz 2" 
Ancestors:  "" okienko
    "" okienko
    "Lista Kontrahentów" okno
    "Z dnia: " okienko
    "Data Faktury Lite wer. 4.2.1.0" okno
    "Pulpit 1" okienko
    [ No Parent ]

==========================================================================
==========================================================================
How found:  Selected from tree...
Name:   "Wiersz 1"
BoundingRectangle:  {l:230 t:224 r:1183 b:246}
IsEnabled:  true
IsOffscreen:    false
IsKeyboardFocusable:    false
HasKeyboardFocus:   false
AccessKey:  ""
ProcessId:  5572
ProviderDescription:    "[pid:5572,providerId:0x0 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
HelpText:   ""
IsDialog:   [Not supported]
LegacyIAccessible.ChildId:  0
LegacyIAccessible.DefaultAction:    ""
LegacyIAccessible.Description:  ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "Wiersz 1"
LegacyIAccessible.Role: wiersz (0x1C)
LegacyIAccessible.State:    wybrany,wybieralny (0x200002)
LegacyIAccessible.Value:    "ZET;Radio ZET;Żurawia 8;00-503;Warszawa;5260205902;(zerowy);(22) 583 32 00;radiozet@radiozet.pl"
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:   false
IsScrollItemPatternAvailable:   false
IsScrollPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    false
IsSpreadsheetItemPatternAvailable:  false
IsSpreadsheetPatternAvailable:  false
IsStylesPatternAvailable:   false
IsSynchronizedInputPatternAvailable:    false
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: "Kod Wiersz 1" element
LastChild:  "E-mail Wiersz 1" element
Next:   "Wiersz 2" 
Previous:   "Wiersz 0" 
Other Props:    Object has no additional properties
Children:   "Kod Wiersz 1" element
    "Nazwa Wiersz 1" element
    "Ulica Wiersz 1" element
    "Kod poczt. Wiersz 1" element
    "Miejscowość Wiersz 1" element
    "NIP Wiersz 1" element
    "Pesel Wiersz 1" element
    "Telefon Wiersz 1" element
    "E-mail Wiersz 1" element
Ancestors:  "DataGridView" tabela
    "" okienko
    "" okienko
    "Lista Kontrahentów" okno
    "Z dnia: " okienko
    "Data Faktury Lite wer. 4.2.1.0" okno
    "Pulpit 1" okienko
    [ No Parent ]
==========================================================================
==========================================================================
How found:  Selected from tree...
Name:   "Kod Wiersz 1"
ControlType:    UIA_DataItemControlTypeId (0xC36D)
LocalizedControlType:   "element"
BoundingRectangle:  {l:230 t:224 r:330 b:246}
IsEnabled:  true
IsOffscreen:    false
IsKeyboardFocusable:    true
HasKeyboardFocus:   false
AccessKey:  ""
ProcessId:  5572
ProviderDescription:    "[pid:5572,providerId:0x0 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
HelpText:   "DataGridViewTextBoxCell(DataGridViewCell)"
IsDialog:   [Not supported]
LegacyIAccessible.ChildId:  0
LegacyIAccessible.DefaultAction:    ""
LegacyIAccessible.Description:  ""
LegacyIAccessible.Help: "DataGridViewTextBoxCell(DataGridViewCell)"
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "Kod Wiersz 1"
LegacyIAccessible.Role: komórka (0x1D)
LegacyIAccessible.State:    wybrany,z możliwością przeniesienia fokusu,wybieralny (0x300002)
LegacyIAccessible.Value:    "ZET"
Value.IsReadOnly:   false
Value.Value:    "ZET"
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:   false
IsScrollItemPatternAvailable:   false
IsScrollPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    false
IsSpreadsheetItemPatternAvailable:  false
IsSpreadsheetPatternAvailable:  false
IsStylesPatternAvailable:   false
IsSynchronizedInputPatternAvailable:    false
IsTableItemPatternAvailable:    false
IsTablePatternAvailable:    false
IsTextChildPatternAvailable:    false
IsTextEditPatternAvailable: false
IsTextPatternAvailable: false
IsTextPattern2Available:    false
IsTogglePatternAvailable:   false
IsTransformPatternAvailable:    false
IsTransform2PatternAvailable:   false
IsValuePatternAvailable:    true
IsVirtualizedItemPatternAvailable:  false
IsWindowPatternAvailable:   false
IsCustomNavigationPatternAvailable: false
IsSelectionPattern2Available:   false
FirstChild: [null]
LastChild:  [null]
Next:   "Nazwa Wiersz 1" element
Previous:   [null]
Other Props:    Object has no additional properties
Children:   Container has no children
Ancestors:  "Wiersz 1" 
    "DataGridView" tabela
    "" okienko
    "" okienko
    "Lista Kontrahentów" okno
    "Z dnia: " okienko
    "Data Faktury Lite wer. 4.2.1.0" okno
    "Pulpit 1" okienko
    [ No Parent ]

==========================================================================
==========================================================================

Thank you very much for your help how it works IUIAutomation in Grid

Piotr

Share this post


Link to post
Share on other sites
junkew

Its hard to answer. It depends if your application supports the patterns for the grid if you can easily iterate rows, cells.

see for details the MS documentation

https://docs.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-support-for-the-datagrid-control-type

 

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

  • 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")  
    • jackchen
      By jackchen
      OK,I've made my "Chrome_KeepLastTab.au3" work.This script adds some features to Chrome browser:
      1. Double click on a tab to close the tab.
      2. Keep last tab:This script monitors your mouse clicks and hotkeys,if you are about to close the last tab within Chrome(click close button on the last tab, middle click/double click on the last tab or press Ctrl + w or Ctrl + {F4}), a new tab will be open and then the old tab be closed.
      #include <WindowsConstants.au3> #include <WinAPI.au3> #include "CUIAutomation2.au3" #AutoIt3Wrapper_UseX64=Y ;Should be used for stuff like tagpoint having right struct etc. when running on a 64 bits os ConsoleWrite("@OSArch: " & @OSArch & ", @AutoItX64: " & @AutoItX64 & @CRLF) Global $DoubleClickTime = 500 Global $UIA_oUIAutomation ; The main library core CUI automation reference Global $hMouseEvent, $hMouseHook Global $aMouseEvent[2] Global $KeepLastTab = True ; settings from ini file If $KeepLastTab Then ;The main object with acces to the windows automation api 3.0 $UIA_oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If IsObj($UIA_oUIAutomation) Then HotKeySet("^w", "Hotkey_Event") ; Ctrl + w to close tab HotKeySet("^{F4}", "Hotkey_Event") ; Ctrl + {F4} to close tab $DoubleClickTime = DllCall("user32.dll", "uint", "GetDoubleClickTime")[0] OnAutoItExitRegister("UnhookMouse") ; Register mouse events callback $hMouseEvent = DllCallbackRegister("Mouse_Event", "int", "int;ptr;ptr") $hMouseHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hMouseEvent), _WinAPI_GetModuleHandle(0)) EndIf EndIf While 1 Sleep(100) WEnd ToolTip("") ; https://www.autoitscript.com/forum/topic/103362-monitoring-mouse-events/ Func Mouse_Event($nCode, $wParam, $lParam) Local $info, $mouseData, $time, $timeDiff If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam) ; Continue processing EndIf $tPoint = _WinAPI_GetMousePos() $hWnd = _WinAPI_WindowFromPoint($tPoint) ; if mouse is on the widget window(class: Chrome_RenderWidgetHostHWND), ; use $hWnd = _WinAPI_GetParent($hWnd) to get the parent Chrome window If Not StringInStr(_WinAPI_GetClassName($hWnd), "Chrome_WidgetWin_") Then ; Chrome_WidgetWin_1: Chrome window ; Chrome_WidgetWin_2: Chrome menu ; ignore non Chrome window Return _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam) EndIf ToolTip($hWnd & " - " & _WinAPI_GetClassName($hWnd)) ;$tagPOINT = "struct;long X;long Y;endstruct" Local Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) $mouseData = DllStructGetData($info, 3) $time = DllStructGetData($info, 5) $timeDiff = $time - $aMouseEvent[1] Local $block Switch $wParam Case $WM_LBUTTONUP $aMouseEvent[1] = $time If $aMouseEvent[0] = "LClick" And ($timeDiff) < $DoubleClickTime Then $aMouseEvent[0] = "LDClick" Else $aMouseEvent[0] = "LClick" EndIf $block = KeepLastTab($hWnd, $aMouseEvent[0]) Case $WM_MBUTTONUP $aMouseEvent[1] = $time If $aMouseEvent[0] = "MClick" And ($timeDiff) < $DoubleClickTime Then $aMouseEvent[0] = "MDClick" Else $aMouseEvent[0] = "MClick" $block = KeepLastTab($hWnd, $aMouseEvent[0]) EndIf EndSwitch If Not $block Then _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam) ; Continue processing EndIf EndFunc ;==>Mouse_Event Func UnhookMouse() _WinAPI_UnhookWindowsHookEx($hMouseHook) $hMouseHook = 0 DllCallbackFree($hMouseEvent) $hMouseEvent = 0 EndFunc ;==>UnhookMouse Func Hotkey_Event() Local $block Local $hWnd = WinGetHandle(WinGetTitle("[ACTIVE]")) If StringInStr(_WinAPI_GetClassName($hWnd), "Chrome_WidgetWin_1") Then ; Chrome_WidgetWin_1, Chrome window $block = KeepLastTab($hWnd, "Hotkey") EndIf If Not $block Then HotKeySet("^w") Send(@HotKeyPressed) HotKeySet("^w", "Hotkey_Event") EndIf EndFunc Func KeepLastTab($hWnd, $action = "LClick") ; Possible $action value: LClick, LDClick, MClick, Hotkey ConsoleWrite(@CRLF & $action & " on a Chrome window: " & $hWnd & @CRLF) Local $aMousePos = MouseGetPos() Local $pChrome, $oChrome $UIA_oUIAutomation.ElementFromHandle($hWnd, $pChrome) ; Window $oChrome = ObjCreateInterface($pChrome, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oChrome) Then ConsoleWrite("Failed to get Chrome object from hWnd." & @CRLF) Return EndIf ;$UIA_ControlTypePropertyId = 30003 $oChromeTabs = UIA_getFirstElement($oChrome, $UIA_ControlTypePropertyId, $UIA_TabControlTypeId, $treescope_subtree) If Not IsObj($oChromeTabs) Then ConsoleWrite("Failed to get Chrome tab bar object." & @CRLF) Return EndIf Local $t $oChromeTabs.GetCurrentPropertyValue($UIA_BoundingRectanglePropertyId, $t) If UBound($t) < 4 Then Return If $action <> "Hotkey" And ($aMousePos[0] < $t[0] Or $aMousePos[0] > $t[2]+$t[0] Or $aMousePos[1] < $t[1] Or $aMousePos[1] > $t[3]+$t[1]) Then ; Mouse not on tabs bar ConsoleWrite("Mouse is not on the tab bar. Ignore and return..." & @CRLF) Return EndIf Local $pTrueCondition, $pElements, $iLength, $oAutomationElementArray $UIA_oUIAutomation.CreateTrueCondition($pTrueCondition) $oCondition = ObjCreateInterface($pTrueCondition, $sIID_IUIAutomationCondition, $dtagIUIAutomationCondition) If Not IsObj($oCondition) Then Return $oChromeTabs.FindAll($treescope_children, $oCondition, $pElements) $oAutomationElementArray = ObjCreateInterface($pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) If Not IsObj($oAutomationElementArray) Then ConsoleWrite("Failed to find all Chrome tabs. " & @CRLF) Return EndIf $oAutomationElementArray.Length($iLength) Local $UIA_pUIElement, $oTab2 Local $iTabs = $iLength - 1 If $iTabs > 1 Then ; more than one tab If $action = "LDClick" Then ConsoleWrite("There are " & $iTabs & " tabs within Chrome window. " & @CRLF) For $i = 1 To $iTabs $oAutomationElementArray.GetElement($i, $UIA_pUIElement) $oTab2 = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oTab2) Then ContinueLoop $oTab2.GetCurrentPropertyValue($UIA_BoundingRectanglePropertyId, $t) If UBound($t) < 4 Then ContinueLoop If $aMousePos[0] >= $t[0] And $aMousePos[0] <= $t[2]+$t[0] And $aMousePos[1] >= $t[1] And $aMousePos[1] <= $t[3]+$t[1] Then ConsoleWrite("You double clicked on one of " & $iTabs & " tabs. Close the tab and return..." & @CRLF) HotKeySet("^w") Send("^w") HotKeySet("^w", "Hotkey_Event") Return True EndIf Next EndIf Return EndIf ConsoleWrite("There is ONLY one tab within Chrome window. " & @CRLF) $oAutomationElementArray.GetElement(1, $UIA_pUIElement) $oTab = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oTab) Then ConsoleWrite("Failed to get the last tab object." & @CRLF) Return EndIf Local $rtTab $oTab.GetCurrentPropertyValue($UIA_BoundingRectanglePropertyId, $rtTab) If UBound($rtTab) < 4 Then Return If $action <> "Hotkey" And ($aMousePos[0] < $rtTab[0] Or $aMousePos[0] > $rtTab[2]+$rtTab[0] Or $aMousePos[1] < $rtTab[1] Or $aMousePos[1] > $rtTab[3]+$rtTab[1]) Then ; Mouse not on the last tab ConsoleWrite("Mouse is not on the last tab. Ignore and return..." & @CRLF) Return EndIf If $action = "LClick" Then $oTabClose = UIA_getFirstElement($oTab, $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $treescope_subtree) If Not IsObj($oTabClose) Then ConsoleWrite("Failed to get the last tab close object." & @CRLF) Return EndIf $oTabClose.GetCurrentPropertyValue($UIA_BoundingRectanglePropertyId, $t) If UBound($t) < 4 Then Return If $aMousePos[0] < $t[0] Or $aMousePos[0] > $t[2]+$t[0] Or $aMousePos[1] < $t[1] Or $aMousePos[1] > $t[3]+$t[1] Then ; Mouse not on the tab close button Return EndIf EndIf ; open a new tab within chrome ConsoleWrite("The last tab is about to be closed, so we have to open a new tab to prevent Chrome window from closing." & @CRLF) Send("^t") ConsoleWrite("A new tab created!" & @CRLF) Sleep(100) ConsoleWrite("Close the old tab and return..." & @CRLF) ;~ Local $pPattern ;~ $oTabClose.GetCurrentPattern($UIA_InvokePatternId, $pPattern) ;~ $oPattern = ObjCreateInterface($pPattern, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern) ;~ If IsObj($oPattern) Then ;~ ConsoleWrite("Invoke to close the tab..." & @CRLF) ;~ $oTabClose.SetFocus() ;~ $oPattern.Invoke() ;~ EndIf _WinAPI_UnhookWindowsHookEx($hMouseHook) $aMousePos = MouseGetPos() If $aMousePos[0] >= $rtTab[0] And $aMousePos[0] <= $rtTab[2]+$rtTab[0] And $aMousePos[1] >= $rtTab[1] And $aMousePos[1] <= $rtTab[3]+$rtTab[1] Then MouseClick("middle", $aMousePos[0], $aMousePos[1], 1, 0) Else MouseClick("middle", $rtTab[0]+$rtTab[2]/2, $rtTab[1]+$rtTab[3]/2, 1, 0) ; close the tab MouseMove($aMousePos[0], $aMousePos[1], 0) ; move mouse back to previous position EndIf ;~ _WinAPI_Mouse_Event($MOUSEEVENTF_MIDDLEDOWN, $rtTab[0]+$rtTab[2]/2, $rtTab[1]+$rtTab[3]/2) ;~ Sleep(100) ;~ _WinAPI_Mouse_Event($MOUSEEVENTF_MIDDLEUP, $rtTab[0]+$rtTab[2]/2, $rtTab[1]+$rtTab[3]/2) $hMouseHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hMouseEvent), _WinAPI_GetModuleHandle(0)) Return True ; to block mouse click/hot key EndFunc Func UIA_getFirstElement($obj, $propertyID, $tval, $treeScope) Local $pCondition, $oCondition $UIA_oUIAutomation.CreatePropertyCondition($propertyID, $tval, $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) Local $UIA_oUIElement, $UIA_pUIElement $t = $obj.Findfirst($treeScope, $oCondition, $UIA_pUIElement) $UIA_oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If IsObj($UIA_oUIElement) Then Return $UIA_oUIElement Return SetError(1, 0, "") EndFunc ;==>UIA_getFirstElement My question is related to #AutoIt3Wrapper_UseX64 when run this script on 64-bit Win 7.
      No mater I set #AutoIt3Wrapper_UseX64=Y or #AutoIt3Wrapper_UseX64=N, this script works very well on hotkey event, while mouse clicks sometimes works if #AutoIt3Wrapper_UseX64=N and sometimes works on Y. Can some one test this and finger out what's wrong?
      Info from SciTe if #AutoIt3Wrapper_UseX64=Y :
      @OSArch: X64, @AutoItX64: 1 Hotkey on a Chrome window: 0x0000000000140330 There is ONLY one tab within Chrome window. The last tab is about to be closed, so we have to open a new tab to prevent Chrome window from closing. A new tab created! Close the old tab and return... LClick on a Chrome window: 0x0000000000140330 There is ONLY one tab within Chrome window. The last tab is about to be closed, so we have to open a new tab to prevent Chrome window from closing. A new tab created! Close the old tab and return... Info if #AutoIt3Wrapper_UseX64=N or comment out this line:
      @OSArch: X64, @AutoItX64: 0 Hotkey on a Chrome window: 0x00140330 There is ONLY one tab within Chrome window. The last tab is about to be closed, so we have to open a new tab to prevent Chrome window from closing. A new tab created! Close the old tab and return... LClick on a Chrome window: 0x00140330 Failed to get Chrome tab bar object. Hotkey events and mouse click events share the same function KeepLastTab($hWnd, $action = "LClick"),Why this function triggered by hotkey works on both 32-bit and 64-bit while that triggered by mouse events failed on 32-bit autoit?
×