Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/08/2022 in all areas

  1. version: 4.0.0 changes Most notable changes: speed and readability. When testing speed i found a minimum increase in speed by ~20%
    5 points
  2. Hi, Thank you for your help, I find the reason, during the retrieving of the characteristic of the file the BOM was detected and the size was 0 wwhich lead to a wrong calculation. I fix it for the next Beta/release Cheers
    3 points
  3. This is my experiment to achieve multi-threading in AutoIt 😅 Source code, usage and examples in this github repo: https://github.com/nomi-san/true-autoit-multi-threading
    1 point
  4. I've made a library, based on AutoItObject UDF with the goal of implementing getter and setter functionality and make it possible to define new object properties in as few steps as possible. Thank you to @trancexx for getting me on the right track, and all users in Hooking into the IDispatch interface for the code to get me going. If I've forgotten to add credit, please let me know Example: #include "AutoItObject_Internal.au3" $myCar = IDispatch() $myCar.make = 'Ford' $myCar.model = 'Mustang' $myCar.year = 1969 $myCar.__defineGetter('DisplayCar', DisplayCar) Func DisplayCar($oThis) Return 'A Beautiful ' & $oThis.parent.year & ' ' & $oThis.parent.make & ' ' & $oThis.parent.model EndFunc MsgBox(0, "", $myCar.DisplayCar) More examples: https://github.com/genius257/AutoItObject-Internal/tree/master/Examples Version: 4.0.1 AutoItObject_Internal.au3 Documentation Edit2 (19th March 2017): First of all, sorry about the lack of updates on this project. I always start too many projects and end up ignoring old projects, if I run into problems ^^'. So I've started moving my AutoIt scripts to GitHub. I will still post the most recent script version here.
    1 point
  5. I've done something like this before, and if I remember correctly, the sent email object is no longer valid after it has been sent. To solve it, I searched the sent email folder for the subject of the just sent email (I think I specified within the last minute as well) and copied that object instead. Edit: And now I see there's another page of replies
    1 point
  6. OK. I will look for another language for my scripts. Bye.  
    1 point
  7. Just a quick update: I have been revamping the dynamic includes process and am now using cache files for the Standard UDFs and Global Const Variables, and made many other changes to speed up the process somewhat. These are the stats I currently get: + initial load of all tables and build cache files !-> Get_Std_UDFs time: 0.76 GlobalConstFiles:71 GlobalConstVars:13270 STDUDFIncludeFiles:82 STDUDFs:3178 USRUDFIncludeFiles:14 USRUDFs:369 Debugging:0-0-0 --> GetCFileUDFs time: 0.12 IncludeFiles:3 UDFs:79 ConstVars:0 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3 --> GetCFileUDFs time: 0.12 IncludeFiles:4 UDFs:192 ConstVars:39 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\SciTE Jump\SciTE Jump.au3 --> GetCFileUDFs time: 0.13 IncludeFiles:3 UDFs:79 ConstVars:0 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3 --> GetCFileUDFs time: 0.12 IncludeFiles:4 UDFs:192 ConstVars:39 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\SciTE Jump\SciTE Jump.au3 + Subsequent SciTE starts without the Include files needing to all be read again by using the cache files !-> Get_Std_UDFs time: 0.19 GlobalConstFiles:71 GlobalConstVars:13270 STDUDFIncludeFiles:82 STDUDFs:3178 USRUDFIncludeFiles:14 USRUDFs:369 Debugging:0-0-0 --> GetCFileUDFs time: 0.12 IncludeFiles:3 UDFs:79 ConstVars:0 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3 --> GetCFileUDFs time: 0.13 IncludeFiles:4 UDFs:192 ConstVars:39 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\SciTE Jump\SciTE Jump.au3 --> GetCFileUDFs time: 0.12 IncludeFiles:3 UDFs:79 ConstVars:0 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3 --> GetCFileUDFs time: 0.13 IncludeFiles:4 UDFs:192 ConstVars:39 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\SciTE Jump\SciTE Jump.au3 The Initialization process checks the FileDate/Time/Size whether it was changed and only will update it's information the tables when either one is different. Summary of the changes: Create cache files for the standard includes and optionally for the File related UDFs & Vars as you need many includes for that to payoff. It is now also getting the Global Enum variables from the *constants*.au3 include files. It gets now all Global Const variables from any File related includes, unlike the Standard includes which are assumed to use *constants*.au3 for its public Global Const variables Reverted Goto Func (Ctrl+J) to only jump to Funcs available in any of the #include files or one of it include tree. Undocumented UDFs from the Standard libraries will not be shown anymore by default, but it is configurable to override the standard au3.api. I am planning some more testing and will publish this version tomorrow unless I hit a bug. Jos
    1 point
  8. IDK. I would expect the saved value to be updated each time the function is called with a new value. 🤷‍♂️
    1 point
  9. 1 point
  10. Jon

    AutoIt v.3.3.16.0 Released

    AutoIt v3.3.16.0 has been released. Thanks to @jpm and the MVPs who were responsible for the majority of code in this version. Download it here. Complete list of changes: History
    1 point
  11. Patterns (actions), 1 - 12 Control patterns are objects that can be used to perform actions on an UI element (window/control). The actual actions are performed by executing the methods of the pattern objects. Control types that are supported by specific control patterns are listed in Control Types and Their Supported Control Patterns. How to create pattern objects and execute pattern methods through UIASpy is described in How to topics 12 and 14. The examples shows how to use control patterns. The examples are tested on Windows 10 and Windows 7. In many examples you need to update eg. control names to your own names. There may also be other values to be updated. Lines to be updated are marked with ; <<<<<<<<<<<<<<<<<<<< Use UIASpy to check and copy the values. All code is stored in Examples\4) Patterns (actions)\<Pattern>\ folders. Patterns (actions): Section 1 - 12: Examples based on File Explorer Top of next post (bottom of this post) Section 13 - 15: Virtual listview item patterns Section 16 - 17: Other control pattern objects File Explorer picture Window patterns (Window) Window Control Pattern (SetWindowVisualState()) Transform Control Pattern (Move()) Treeview patterns (Tree, TreeItem) ExpandCollapse Control Pattern (Expand(), Collapse()) ScrollItem Control Pattern (ScrollIntoView()) Scroll Control Pattern (Scroll()) Does not work on Windows 7 ($oScrollPattern1 ERR) Listview patterns (List, ListItem) Grid Control Pattern (GetItem()) Table Control Pattern (GetCurrentColumnHeaders()) Invoke Control Pattern (Invoke()) MultipleView Control Pattern (GetCurrentSupportedViews()) SelectionItem Control Pattern (Select(), AddToSelection()) Selection Control Pattern (GetCurrentSelection()) Virtual listview item patterns File Explorer picture ItemContainer Control Pattern VirtualizedItem Control Pattern Other control pattern objects Value Control Pattern RangeValue Control Pattern 1. File Explorer picture 2. Window Control Pattern From Microsoft documentation: The Window control pattern supports controls that provide fundamental window-based functionality within a traditional GUI. This includes top-level application windows, multiple-document interface (MDI) child windows, resizable split pane controls, modal dialogs and balloon help windows. Preparation File Explorer should look as shown in the picture. Open UIASpy, place the mouse over window title bar, press F2. Code The code created with UIASpy shows how to alternately switch the window visual state between normal and minimized (Window.au3, Window-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Window Pattern (action) Object --- ConsoleWrite( "--- Window Pattern (action) Object ---" & @CRLF ) Local $pWindowPattern1, $oWindowPattern1 $oWindow1.GetCurrentPattern( $UIA_WindowPatternId, $pWindowPattern1 ) $oWindowPattern1 = ObjCreateInterface( $pWindowPattern1, $sIID_IUIAutomationWindowPattern, $dtagIUIAutomationWindowPattern ) If Not IsObj( $oWindowPattern1 ) Then Return ConsoleWrite( "$oWindowPattern1 ERR" & @CRLF ) ConsoleWrite( "$oWindowPattern1 OK" & @CRLF ) ; --- Control Pattern Properties --- ConsoleWrite( "--- Control Pattern Properties ---" & @CRLF ) Local $iWindowWindowVisualState1 $oWindow1.GetCurrentPropertyValue( $UIA_WindowWindowVisualStatePropertyId, $iWindowWindowVisualState1 ) ConsoleWrite( "$iWindowWindowVisualState1 = " & $iWindowWindowVisualState1 & @CRLF ) ; --- Copy element info --- ; $UIA_WindowWindowVisualStatePropertyId $WindowVisualState_Normal ; --- Window Pattern (action) Methods --- ConsoleWrite( "--- Window Pattern (action) Methods ---" & @CRLF ) If $iWindowWindowVisualState1 = $WindowVisualState_Normal Then $oWindowPattern1.SetWindowVisualState( $WindowVisualState_Minimized ) ConsoleWrite( "$oWindowPattern1.SetWindowVisualState( $WindowVisualState_Minimized )" & @CRLF ) Else $oWindowPattern1.SetWindowVisualState( $WindowVisualState_Normal ) ConsoleWrite( "$oWindowPattern1.SetWindowVisualState( $WindowVisualState_Normal )" & @CRLF ) EndIf EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Window Pattern (action) Object --- $oWindowPattern1 OK --- Control Pattern Properties --- $iWindowWindowVisualState1 = 0 --- Window Pattern (action) Methods --- $oWindowPattern1.SetWindowVisualState( $WindowVisualState_Minimized ) Remarks WindowVisualState values are found in CUIAutomation2.au3 and Microsoft documentation. 3. Transform Control Pattern From Microsoft documentation: The Transform control pattern is used to support controls that can be moved, resized, or rotated within a two-dimensional space. Preparation File Explorer should look as shown in the picture. Open UIASpy, place the mouse over window title bar, press F2. Code The code created with UIASpy shows how to move the window horizontally 100 pixels forth and back (Transform.au3, Transform-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder #include "..\..\..\Includes\UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Transform Pattern (action) Object --- ConsoleWrite( "--- Transform Pattern (action) Object ---" & @CRLF ) Local $pTransformPattern1, $oTransformPattern1 $oWindow1.GetCurrentPattern( $UIA_TransformPatternId, $pTransformPattern1 ) $oTransformPattern1 = ObjCreateInterface( $pTransformPattern1, $sIID_IUIAutomationTransformPattern, $dtagIUIAutomationTransformPattern ) If Not IsObj( $oTransformPattern1 ) Then Return ConsoleWrite( "$oTransformPattern1 ERR" & @CRLF ) ConsoleWrite( "$oTransformPattern1 OK" & @CRLF ) ; --- Element Properties (information) --- ConsoleWrite( "--- Element Properties (information) ---" & @CRLF ) Local $asBoundingRectangle1 $oWindow1.GetCurrentPropertyValue( $UIA_BoundingRectanglePropertyId, $asBoundingRectangle1 ) UIA_GetArrayPropertyValueAsString( $asBoundingRectangle1 ) ConsoleWrite( "$asBoundingRectangle1 = " & $asBoundingRectangle1 & @CRLF ) ; --- Copy element info --- ; $UIA_BoundingRectanglePropertyId l=250,t=50,w=1000,h=900 ; --- Transform Pattern (action) Methods --- ConsoleWrite( "--- Transform Pattern (action) Methods ---" & @CRLF ) If StringSplit( $asBoundingRectangle1, ",", 2 )[0] = 250 Then ; 2 = $STR_NOCOUNT ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $oTransformPattern1.Move( StringSplit( $asBoundingRectangle1, ",", 2 )[0] + 100, 50 ) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite( "$oTransformPattern1.Move( +100 )" & @CRLF ) Else $oTransformPattern1.Move( StringSplit( $asBoundingRectangle1, ",", 2 )[0] - 100, 50 ) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite( "$oTransformPattern1.Move( -100 )" & @CRLF ) EndIf EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Transform Pattern (action) Object --- $oTransformPattern1 OK --- Element Properties (information) --- $asBoundingRectangle1 = 250,50,1000,900 --- Transform Pattern (action) Methods --- $oTransformPattern1.Move( +100 ) Remarks Note the use of UIA_GetArrayPropertyValueAsString() function and the inclusion of UIA_Functions.au3 UDF. 4. ExpandCollapse Control Pattern From Microsoft documentation: The ExpandCollapse control pattern is used to support controls that visually expand to display more content and collapse to hide content. Eg. a treeview element with child elements. Preparation File Explorer should look as shown in the picture. The C-drive in the treeview should be collapsed. Open UIASpy, place the mouse over the C-drive, press F1. Code The code generated with UIASpy shows how to alternately expand and collapse the C-drive (ExpandCollapse.au3, ExpandCollapse-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) ; <<<<<<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2, $pCondition3, $pAndCondition3 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TreeItemControlTypeId, $pCondition2 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition3 ) ; <<<<<<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition2, $pCondition3, $pAndCondition3 ) If Not $pAndCondition3 Then Return ConsoleWrite( "$pAndCondition3 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition3 OK" & @CRLF ) Local $pTreeItem1, $oTreeItem1 $oWindow1.FindFirst( $TreeScope_Descendants, $pAndCondition3, $pTreeItem1 ) $oTreeItem1 = ObjCreateInterface( $pTreeItem1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oTreeItem1 ) Then Return ConsoleWrite( "$oTreeItem1 ERR" & @CRLF ) ConsoleWrite( "$oTreeItem1 OK" & @CRLF ) ; --- ExpandCollapse Pattern (action) Object --- ConsoleWrite( "--- ExpandCollapse Pattern (action) Object ---" & @CRLF ) Local $pExpandCollapsePattern1, $oExpandCollapsePattern1 $oTreeItem1.GetCurrentPattern( $UIA_ExpandCollapsePatternId, $pExpandCollapsePattern1 ) $oExpandCollapsePattern1 = ObjCreateInterface( $pExpandCollapsePattern1, $sIID_IUIAutomationExpandCollapsePattern, $dtagIUIAutomationExpandCollapsePattern ) If Not IsObj( $oExpandCollapsePattern1 ) Then Return ConsoleWrite( "$oExpandCollapsePattern1 ERR" & @CRLF ) ConsoleWrite( "$oExpandCollapsePattern1 OK" & @CRLF ) ; --- Control Pattern Properties --- ConsoleWrite( "--- Control Pattern Properties ---" & @CRLF ) Local $iExpandCollapseExpandCollapseState1 $oTreeItem1.GetCurrentPropertyValue( $UIA_ExpandCollapseExpandCollapseStatePropertyId, $iExpandCollapseExpandCollapseState1 ) ConsoleWrite( "$iExpandCollapseExpandCollapseState1 = " & $iExpandCollapseExpandCollapseState1 & @CRLF ) ; --- Copy element info --- ; $UIA_ExpandCollapseExpandCollapseStatePropertyId $ExpandCollapseState_Collapsed ; --- ExpandCollapse Pattern (action) Methods --- ConsoleWrite( "--- ExpandCollapse Pattern (action) Methods ---" & @CRLF ) If $iExpandCollapseExpandCollapseState1 = $ExpandCollapseState_Collapsed Then $oExpandCollapsePattern1.Expand() ConsoleWrite( "$oExpandCollapsePattern1.Expand()" & @CRLF ) Else $oExpandCollapsePattern1.Collapse() ConsoleWrite( "$oExpandCollapsePattern1.Collapse()" & @CRLF ) EndIf EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Find window/control --- $pAndCondition3 OK $oTreeItem1 OK --- ExpandCollapse Pattern (action) Object --- $oExpandCollapsePattern1 OK --- Control Pattern Properties --- $iExpandCollapseExpandCollapseState1 = 0 --- ExpandCollapse Pattern (action) Methods --- $oExpandCollapsePattern1.Expand() Remarks ExpandCollapseState values are found in CUIAutomation2.au3 and Microsoft documentation. 5. ScrollItem Control Pattern From Microsoft documentation: The ScrollItem control pattern acts as a communication channel between a child control and its container to ensure that the container can change the currently visible content (or region) within its viewport to display the child control. The ScrollItem pattern object implements one method only: ScrollIntoView(). It can be used to make a child control visible in its parent container control. Eg. to make a treeview item visible in the treeview. Preparation File Explorer should look as shown in the picture. The C-drive in the treeview should be collapsed. Open UIASpy, place the mouse over the C-drive, press F1. Expand the C-drive in the treeview. Expand Windows folder in the treeview. Windows folder should be visible in top of the treeview. The C-drive should be scrolled out of sight. Code The code created with UIASpy shows how to scroll the C-drive into sight (ScrollItem.au3, ScrollItem-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2, $pCondition3, $pAndCondition3 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TreeItemControlTypeId, $pCondition2 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition3 ) $oUIAutomation.CreateAndCondition( $pCondition2, $pCondition3, $pAndCondition3 ) If Not $pAndCondition3 Then Return ConsoleWrite( "$pAndCondition3 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition3 OK" & @CRLF ) Local $pTreeItem1, $oTreeItem1 $oWindow1.FindFirst( $TreeScope_Descendants, $pAndCondition3, $pTreeItem1 ) $oTreeItem1 = ObjCreateInterface( $pTreeItem1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oTreeItem1 ) Then Return ConsoleWrite( "$oTreeItem1 ERR" & @CRLF ) ConsoleWrite( "$oTreeItem1 OK" & @CRLF ) ; --- ScrollItem Pattern (action) Object --- ConsoleWrite( "--- ScrollItem Pattern (action) Object ---" & @CRLF ) Local $pScrollItemPattern1, $oScrollItemPattern1 $oTreeItem1.GetCurrentPattern( $UIA_ScrollItemPatternId, $pScrollItemPattern1 ) $oScrollItemPattern1 = ObjCreateInterface( $pScrollItemPattern1, $sIID_IUIAutomationScrollItemPattern, $dtagIUIAutomationScrollItemPattern ) If Not IsObj( $oScrollItemPattern1 ) Then Return ConsoleWrite( "$oScrollItemPattern1 ERR" & @CRLF ) ConsoleWrite( "$oScrollItemPattern1 OK" & @CRLF ) ; --- ScrollItem Pattern (action) Methods --- ConsoleWrite( "--- ScrollItem Pattern (action) Methods ---" & @CRLF ) $oScrollItemPattern1.ScrollIntoView() ConsoleWrite( "$oScrollItemPattern1.ScrollIntoView()" & @CRLF ) EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Find window/control --- $pAndCondition3 OK $oTreeItem1 OK --- ScrollItem Pattern (action) Object --- $oScrollItemPattern1 OK --- ScrollItem Pattern (action) Methods --- $oScrollItemPattern1.ScrollIntoView() 6. Scroll Control Pattern From Microsoft documentation: The Scroll control pattern is used to support a control that acts as a scrollable container for a collection of child objects. Preparation Run the ScrollItem example in the section above. The C-drive should be visible near the top of the treeview. The treeview scrollbar thumb should also be visible near the top of the treeview. Open UIASpy, place the mouse over the C-drive, press F2. The treeview should be detected. Code The UIASpy generated code shows how to scroll the treeview one page down (Scroll.au3, Scroll-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) ; <<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TreeControlTypeId, $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) Local $pTree1, $oTree1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition2, $pTree1 ) $oTree1 = ObjCreateInterface( $pTree1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oTree1 ) Then Return ConsoleWrite( "$oTree1 ERR" & @CRLF ) ConsoleWrite( "$oTree1 OK" & @CRLF ) ; --- Scroll Pattern (action) Object --- ConsoleWrite( "--- Scroll Pattern (action) Object ---" & @CRLF ) Local $pScrollPattern1, $oScrollPattern1 $oTree1.GetCurrentPattern( $UIA_ScrollPatternId, $pScrollPattern1 ) $oScrollPattern1 = ObjCreateInterface( $pScrollPattern1, $sIID_IUIAutomationScrollPattern, $dtagIUIAutomationScrollPattern ) If Not IsObj( $oScrollPattern1 ) Then Return ConsoleWrite( "$oScrollPattern1 ERR" & @CRLF ) ConsoleWrite( "$oScrollPattern1 OK" & @CRLF ) ; --- Scroll Pattern (action) Methods --- ConsoleWrite( "--- Scroll Pattern (action) Methods ---" & @CRLF ) $oScrollPattern1.Scroll( $ScrollAmount_NoAmount, $ScrollAmount_LargeIncrement ) ; Horizontally, vertically ConsoleWrite( "$oScrollPattern1.Scroll()" & @CRLF ) EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Find window/control --- $pCondition2 OK $oTree1 OK --- Scroll Pattern (action) Object --- $oScrollPattern1 OK --- Scroll Pattern (action) Methods --- $oScrollPattern1.Scroll() Remarks ScrollAmount values are found in CUIAutomation2.au3 and Microsoft documentation. 7. Grid Control Pattern From Microsoft documentation: The Grid control pattern supports controls that acts as a container for a collection of child controls that are organized in a two-dimensional logical coordinate system that can be traversed by row and column. These child controls can eg. be the individual cells in a listview. Preparation File Explorer should look as shown in the picture. Open UIASpy, place the mouse over the first visible item in the listview, press F2, press F7. F2 detects the listview item that's parent for the individual item cells (image and edit controls). F7 navigates to the parent control of the item which is the listview. Code Code as created with UIASpy to get the text in a listview cell given by row and column number (Grid.au3, Grid-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) ; <<<<<<<<<<<<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) Local $pList1, $oList1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition2, $pList1 ) $oList1 = ObjCreateInterface( $pList1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oList1 ) Then Return ConsoleWrite( "$oList1 ERR" & @CRLF ) ConsoleWrite( "$oList1 OK" & @CRLF ) ; --- Grid Pattern (action) Object --- ConsoleWrite( "--- Grid Pattern (action) Object ---" & @CRLF ) Local $pGridPattern1, $oGridPattern1 $oList1.GetCurrentPattern( $UIA_GridPatternId, $pGridPattern1 ) $oGridPattern1 = ObjCreateInterface( $pGridPattern1, $sIID_IUIAutomationGridPattern, $dtagIUIAutomationGridPattern ) If Not IsObj( $oGridPattern1 ) Then Return ConsoleWrite( "$oGridPattern1 ERR" & @CRLF ) ConsoleWrite( "$oGridPattern1 OK" & @CRLF ) ; --- Control Pattern Properties --- ConsoleWrite( "--- Control Pattern Properties ---" & @CRLF ) Local $iGridColumnCount1 $oList1.GetCurrentPropertyValue( $UIA_GridColumnCountPropertyId, $iGridColumnCount1 ) ConsoleWrite( "$iGridColumnCount1 = " & $iGridColumnCount1 & @CRLF ) Local $iGridRowCount1 $oList1.GetCurrentPropertyValue( $UIA_GridRowCountPropertyId, $iGridRowCount1 ) ConsoleWrite( "$iGridRowCount1 = " & $iGridRowCount1 & @CRLF ) ; --- Grid Pattern (action) Methods --- ConsoleWrite( "--- Grid Pattern (action) Methods ---" & @CRLF ) Local $pEdit1, $oEdit1 $oGridPattern1.GetItem( 4, 0, $pEdit1 ) ; Row, col ConsoleWrite( "$oGridPattern1.GetItem()" & @CRLF ) $oEdit1 = ObjCreateInterface( $pEdit1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) ; --- Control Pattern Properties --- ConsoleWrite( "--- Control Pattern Properties ---" & @CRLF ) Local $sValueValue1 $oEdit1.GetCurrentPropertyValue( $UIA_ValueValuePropertyId, $sValueValue1 ) ConsoleWrite( "$sValueValue1 = " & $sValueValue1 & @CRLF ) EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Find window/control --- $pCondition2 OK $oList1 OK --- Grid Pattern (action) Object --- $oGridPattern1 OK --- Control Pattern Properties --- $iGridColumnCount1 = 4 $iGridRowCount1 = 21 --- Grid Pattern (action) Methods --- $oGridPattern1.GetItem() --- Control Pattern Properties --- $sValueValue1 = Intel Remarks Read about $oGridPattern.GetItem() in the Microsoft documentation. 8. Table Control Pattern From Microsoft documentation: The Table control pattern is used to support controls that act as containers for a collection of child elements. The children of the container element must be organized in a two-dimensional logical coordinate system that can be traversed by row and column. This control pattern is analogous to the Grid control pattern with the distinction that the Table control pattern must also expose a column and/or row header relationship for each child element. The Table control pattern can be used to get information about the header control in a listview. Preparation File Explorer should look as shown in the picture. Open UIASpy, place the mouse over the header control in the listview, press F2, press F7. F2 detects the header control that's parent for the individual header items. F7 navigates to the parent control of the header which is the listview. Code The code generated with UIASpy shows how to get information about the header control (Table.au3, Table-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) ; <<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) Local $pList1, $oList1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition2, $pList1 ) $oList1 = ObjCreateInterface( $pList1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oList1 ) Then Return ConsoleWrite( "$oList1 ERR" & @CRLF ) ConsoleWrite( "$oList1 OK" & @CRLF ) ; --- Table Pattern (action) Object --- ConsoleWrite( "--- Table Pattern (action) Object ---" & @CRLF ) Local $pTablePattern1, $oTablePattern1 $oList1.GetCurrentPattern( $UIA_TablePatternId, $pTablePattern1 ) $oTablePattern1 = ObjCreateInterface( $pTablePattern1, $sIID_IUIAutomationTablePattern, $dtagIUIAutomationTablePattern ) If Not IsObj( $oTablePattern1 ) Then Return ConsoleWrite( "$oTablePattern1 ERR" & @CRLF ) ConsoleWrite( "$oTablePattern1 OK" & @CRLF ) ; --- Table Pattern (action) Methods --- ConsoleWrite( "--- Table Pattern (action) Methods ---" & @CRLF ) Local $pElements $oTablePattern1.GetCurrentColumnHeaders( $pElements ) ConsoleWrite( "$oTablePattern1.GetCurrentColumnHeaders()" & @CRLF ) ; --- Code Snippets --- ConsoleWrite( "--- Code Snippets ---" & @CRLF ) Local $oAutomationElementArray1, $iLength1 ; $pElements is a pointer to an UI Automation element array $oAutomationElementArray1 = ObjCreateInterFace( $pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray ) $oAutomationElementArray1.Length( $iLength1 ) If Not $iLength1 Then Return ConsoleWrite( "$iLength1 = 0 ERR" & @CRLF ) ConsoleWrite( "$iLength1 = " & $iLength1 & @CRLF ) ; --- Code Snippets --- ConsoleWrite( "--- Code Snippets ---" & @CRLF ) Local $pElement1, $oElement1, $sValue1 For $i = 0 To $iLength1 - 1 $oAutomationElementArray1.GetElement( $i, $pElement1 ) $oElement1 = ObjCreateInterface( $pElement1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oElement1.GetCurrentPropertyValue( $UIA_ClassNamePropertyId, $sValue1 ) ; $UIA_ClassNamePropertyId is used as example ConsoleWrite( "$sValue1 = " & $sValue1 & @CRLF ) $oElement1.GetCurrentPropertyValue( $UIA_NamePropertyId, $sValue1 ) ConsoleWrite( "$sValue1 = " & $sValue1 & @CRLF ) Next ; --- Copy element info --- ; $UIA_NamePropertyId Name EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Find window/control --- $pCondition2 OK $oList1 OK --- Table Pattern (action) Object --- $oTablePattern1 OK --- Table Pattern (action) Methods --- $oTablePattern1.GetCurrentColumnHeaders() --- Code Snippets --- $iLength1 = 4 --- Code Snippets --- $sValue1 = UIColumnHeader $sValue1 = Name $sValue1 = UIColumnHeader $sValue1 = Date modified $sValue1 = UIColumnHeader $sValue1 = Type $sValue1 = UIColumnHeader $sValue1 = Size Remarks Note the loop in bottom of the code that's used to traverse the UI Automation element array to get information about the individual header elements. The $UIA_NamePropertyId is copied in UIASpy from the Name header item. 9. Invoke Control Pattern From Microsoft documentation: The Invoke control pattern is used to support controls that do not maintain state when activated but rather initiate or perform a single, unambiguous action. Controls that do maintain state, such as check boxes and radio buttons, must instead implement Toggle and Selection patterns respectively. In short, the Invoke pattern is used to implement the click action. Preparation File Explorer should look as shown in the picture. Select Windows folder in the listview. Open UIASpy, place the mouse over Windows folder, press F2. F2 detects the listview item that's parent for the individual listview fields (image and edit controls). Code Code to click the Windows folder as generated with UIASpy (Invoke.au3, Invoke-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) ; <<<<<<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2, $pCondition3, $pAndCondition3 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListItemControlTypeId, $pCondition2 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Windows", $pCondition3 ) ; <<<<<<<<<<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition2, $pCondition3, $pAndCondition3 ) If Not $pAndCondition3 Then Return ConsoleWrite( "$pAndCondition3 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition3 OK" & @CRLF ) Local $pListItem1, $oListItem1 $oWindow1.FindFirst( $TreeScope_Descendants, $pAndCondition3, $pListItem1 ) $oListItem1 = ObjCreateInterface( $pListItem1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oListItem1 ) Then Return ConsoleWrite( "$oListItem1 ERR" & @CRLF ) ConsoleWrite( "$oListItem1 OK" & @CRLF ) ; --- Invoke Pattern (action) Object --- ConsoleWrite( "--- Invoke Pattern (action) Object ---" & @CRLF ) Local $pInvokePattern1, $oInvokePattern1 $oListItem1.GetCurrentPattern( $UIA_InvokePatternId, $pInvokePattern1 ) $oInvokePattern1 = ObjCreateInterface( $pInvokePattern1, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvokePattern1 ) Then Return ConsoleWrite( "$oInvokePattern1 ERR" & @CRLF ) ConsoleWrite( "$oInvokePattern1 OK" & @CRLF ) ; --- Invoke Pattern (action) Methods --- ConsoleWrite( "--- Invoke Pattern (action) Methods ---" & @CRLF ) $oInvokePattern1.Invoke() ConsoleWrite( "$oInvokePattern1.Invoke()" & @CRLF ) EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Find window/control --- $pAndCondition3 OK $oListItem1 OK --- Invoke Pattern (action) Object --- $oInvokePattern1 OK --- Invoke Pattern (action) Methods --- $oInvokePattern1.Invoke() Remarks Sometimes the Invoke() method does not work for a control. Mainly because the method isn't implemented by the provider. The most common workaround is to perform a MouseClick in the middle of the control (calculated from bounding rectangel). See How to topic number 16. Another workaround is to use classic automation code if possible. See How to topic number 17. Examples Other examples: MouseClick in middle of the control: How to topic number 16. Click with classic automation code: How to topic number 17. 10. MultipleView Control Pattern From Microsoft documentation: The MultipleView control pattern is used to support controls that provide, and are able to switch between, multiple representations of the same information or the same set of child controls. Examples of controls that can present multiple views include the listview (which can show its contents as thumbnails, tiles, icons, or details), Microsoft Excel charts (pie, line, bar, cell value with a formula), Microsoft Word documents (normal, web layout, print layout, reading layout, outline), Microsoft Outlook calendar (year, month, week, day), and Microsoft Windows Media Player skins. Preparation File Explorer should look as shown in the picture. Open UIASpy, place the mouse over the first visible item in the listview, press F2, press F7. F2 detects the listview item that's parent for the individual item cells (image and edit controls). F7 navigates to the parent control of the item which is the listview. Code The code generated with UIASpy shows how to get an array of view identifiers (integers). The returned array is a safearray of integers. The code also shows how to extract the integers from the safearray (MultipleView.au3, MultipleView-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder #include "..\..\..\Includes\UIA_SafeArray.au3" ; Can be copied from UIASpy Includes folder #include "..\..\..\Includes\UIA_Variant.au3" ; Can be copied from UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) ; <<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) Local $pList1, $oList1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition2, $pList1 ) $oList1 = ObjCreateInterface( $pList1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oList1 ) Then Return ConsoleWrite( "$oList1 ERR" & @CRLF ) ConsoleWrite( "$oList1 OK" & @CRLF ) ; --- MultipleView Pattern (action) Object --- ConsoleWrite( "--- MultipleView Pattern (action) Object ---" & @CRLF ) Local $pMultipleViewPattern1, $oMultipleViewPattern1 $oList1.GetCurrentPattern( $UIA_MultipleViewPatternId, $pMultipleViewPattern1 ) $oMultipleViewPattern1 = ObjCreateInterface( $pMultipleViewPattern1, $sIID_IUIAutomationMultipleViewPattern, $dtagIUIAutomationMultipleViewPattern ) If Not IsObj( $oMultipleViewPattern1 ) Then Return ConsoleWrite( "$oMultipleViewPattern1 ERR" & @CRLF ) ConsoleWrite( "$oMultipleViewPattern1 OK" & @CRLF ) ; --- MultipleView Pattern (action) Methods --- ConsoleWrite( "--- MultipleView Pattern (action) Methods ---" & @CRLF ) Local $pSafeArray $oMultipleViewPattern1.GetCurrentSupportedViews( $pSafeArray ) ConsoleWrite( "$oMultipleViewPattern1.GetCurrentSupportedViews()" & @CRLF ) If Not $pSafeArray Then Return ConsoleWrite( "$pSafeArray ERR" & @CRLF ) ConsoleWrite( "$pSafeArray OK" & @CRLF ) Local $iElements, $iViewId SafeArrayGetUBound( $pSafeArray, 1, $iElements ) ConsoleWrite( "$iElements = " & $iElements & @CRLF ) For $i = 0 To $iElements - 1 SafeArrayGetElement( $pSafeArray, $i, $iViewId ) ConsoleWrite( "$iViewId = " & $iViewId & @CRLF ) Next EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Find window/control --- $pCondition2 OK $oList1 OK --- MultipleView Pattern (action) Object --- $oMultipleViewPattern1 OK --- MultipleView Pattern (action) Methods --- $oMultipleViewPattern1.GetCurrentSupportedViews() $pSafeArray OK $iElements = 7 $iViewId = 0 $iViewId = 1 $iViewId = 2 $iViewId = 3 $iViewId = 4 $iViewId = 5 $iViewId = 6 Remarks Note that UIA_SafeArray.au3 and UIA_Variant.au3 are included in top of the code to be able to handle safearrays. Note also how the view identifiers are extracted from the safearray returned by $oMultipleViewPattern.GetCurrentSupportedViews() in bottom of the code. Read about $oMultipleViewPattern.GetCurrentSupportedViews() in the Microsoft documentation. 11. SelectionItem Control Pattern From Microsoft documentation: The SelectionItem control pattern is used to support controls that act as individual, selectable child items of container controls. Eg. listbox and listview items. Preparation File Explorer should look as shown in the picture. Open UIASpy, place the mouse over the first visible item in the listview, press F2. F2 detects the listview item that's parent for the individual listview fields (image and edit controls). Code The code created with UIASpy shows how to select the first item in the listview and then select additional four items: (SelectionItem.au3, SelectionItem-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) ; <<<<<<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2, $pCondition3, $pAndCondition3 $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "0", $pCondition2 ) $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListItemControlTypeId, $pCondition3 ) $oUIAutomation.CreateAndCondition( $pCondition2, $pCondition3, $pAndCondition3 ) If Not $pAndCondition3 Then Return ConsoleWrite( "$pAndCondition3 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition3 OK" & @CRLF ) Local $pListItem1, $oListItem1 $oWindow1.FindFirst( $TreeScope_Descendants, $pAndCondition3, $pListItem1 ) $oListItem1 = ObjCreateInterface( $pListItem1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oListItem1 ) Then Return ConsoleWrite( "$oListItem1 ERR" & @CRLF ) ConsoleWrite( "$oListItem1 OK" & @CRLF ) ; --- SelectionItem Pattern (action) Object --- ConsoleWrite( "--- SelectionItem Pattern (action) Object ---" & @CRLF ) Local $pSelectionItemPattern1, $oSelectionItemPattern1 $oListItem1.GetCurrentPattern( $UIA_SelectionItemPatternId, $pSelectionItemPattern1 ) $oSelectionItemPattern1 = ObjCreateInterface( $pSelectionItemPattern1, $sIID_IUIAutomationSelectionItemPattern, $dtagIUIAutomationSelectionItemPattern ) If Not IsObj( $oSelectionItemPattern1 ) Then Return ConsoleWrite( "$oSelectionItemPattern1 ERR" & @CRLF ) ConsoleWrite( "$oSelectionItemPattern1 OK" & @CRLF ) ; --- SelectionItem Pattern (action) Methods --- ConsoleWrite( "--- SelectionItem Pattern (action) Methods ---" & @CRLF ) $oSelectionItemPattern1.Select() ConsoleWrite( "$oSelectionItemPattern1.Select()" & @CRLF ) ; --- Add 4 items to selection --- ConsoleWrite( "--- Add 4 items to selection ---" & @CRLF ) For $i = 1 To 4 ; 3 lines copied from code above $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, String( $i ), $pCondition2 ) ; Modified: "0" --> String( $i ) $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListItemControlTypeId, $pCondition3 ) $oUIAutomation.CreateAndCondition( $pCondition2, $pCondition3, $pAndCondition3 ) ; 2 lines copied from code above $oWindow1.FindFirst( $TreeScope_Descendants, $pAndCondition3, $pListItem1 ) $oListItem1 = ObjCreateInterface( $pListItem1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) ; 2 lines copied from code above $oListItem1.GetCurrentPattern( $UIA_SelectionItemPatternId, $pSelectionItemPattern1 ) $oSelectionItemPattern1 = ObjCreateInterface( $pSelectionItemPattern1, $sIID_IUIAutomationSelectionItemPattern, $dtagIUIAutomationSelectionItemPattern ) ; 2 lines copied from SelectionItem-a.au3 $oSelectionItemPattern1.AddToSelection() ConsoleWrite( "$oSelectionItemPattern1.AddToSelection()" & @CRLF ) Next EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Find window/control --- $pAndCondition3 OK $oListItem1 OK --- SelectionItem Pattern (action) Object --- $oSelectionItemPattern1 OK --- SelectionItem Pattern (action) Methods --- $oSelectionItemPattern1.Select() --- Add 4 items to selection --- $oSelectionItemPattern1.AddToSelection() $oSelectionItemPattern1.AddToSelection() $oSelectionItemPattern1.AddToSelection() $oSelectionItemPattern1.AddToSelection() Remarks Note the For-loop to add 4 items to selection. 12. Selection Control Pattern From Microsoft documentation: The Selection control pattern is used to support controls that act as containers for a collection of selectable child items. Eg. a listview with selectable items. Preparation Run the SelectionItem example in the section above. Five items should be selected in top of the listview. Open UIASpy, place the mouse over the first selected item, press F2, press F7. The listview should be detected. F2 detects the listview item that's parent for the individual item cells (image and edit controls). F7 navigates to the parent control of the item which is the listview. Code The UIASpy generated code shows how to get the selected listview items as an UI Automation element array and how to get access to the individual elements in the array: (Selection.au3, Selection-a.au3 contains code directly from UIASpy): #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 "..\..\..\Includes\CUIAutomation2.au3" ; Get proper version in UIASpy Includes folder ;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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_IUIAutomationElement, $dtagIUIAutomationElement ) 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_ClassNamePropertyId, "CabinetWClass", $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "System (C:)", $pCondition1 ) ; <<<<<<<<<<<<< $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pWindow1, $oWindow1 $oDesktop.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pWindow1 ) $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF ) ConsoleWrite( "$oWindow1 OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) Local $pList1, $oList1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition2, $pList1 ) $oList1 = ObjCreateInterface( $pList1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oList1 ) Then Return ConsoleWrite( "$oList1 ERR" & @CRLF ) ConsoleWrite( "$oList1 OK" & @CRLF ) ; --- Selection Pattern (action) Object --- ConsoleWrite( "--- Selection Pattern (action) Object ---" & @CRLF ) Local $pSelectionPattern1, $oSelectionPattern1 $oList1.GetCurrentPattern( $UIA_SelectionPatternId, $pSelectionPattern1 ) $oSelectionPattern1 = ObjCreateInterface( $pSelectionPattern1, $sIID_IUIAutomationSelectionPattern, $dtagIUIAutomationSelectionPattern ) If Not IsObj( $oSelectionPattern1 ) Then Return ConsoleWrite( "$oSelectionPattern1 ERR" & @CRLF ) ConsoleWrite( "$oSelectionPattern1 OK" & @CRLF ) ; --- Selection Pattern (action) Methods --- ConsoleWrite( "--- Selection Pattern (action) Methods ---" & @CRLF ) Local $pElements $oSelectionPattern1.GetCurrentSelection( $pElements ) ConsoleWrite( "$oSelectionPattern1.GetCurrentSelection()" & @CRLF ) ; --- Code Snippets --- ConsoleWrite( "--- Code Snippets ---" & @CRLF ) Local $oAutomationElementArray1, $iLength1 ; $pElements is a pointer to an UI Automation element array $oAutomationElementArray1 = ObjCreateInterFace( $pElements, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray ) $oAutomationElementArray1.Length( $iLength1 ) If Not $iLength1 Then Return ConsoleWrite( "$iLength1 = 0 ERR" & @CRLF ) ConsoleWrite( "$iLength1 = " & $iLength1 & @CRLF ) ; --- Code Snippets --- ConsoleWrite( "--- Code Snippets ---" & @CRLF ) Local $pElement1, $oElement1, $sValue1 For $i = 0 To $iLength1 - 1 $oAutomationElementArray1.GetElement( $i, $pElement1 ) $oElement1 = ObjCreateInterface( $pElement1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oElement1.GetCurrentPropertyValue( $UIA_ClassNamePropertyId, $sValue1 ) ; $UIA_ClassNamePropertyId is used as example ConsoleWrite( "$sValue1 = " & $sValue1 & @CRLF ) $oElement1.GetCurrentPropertyValue( $UIA_ValueValuePropertyId, $sValue1 ) ConsoleWrite( "$sValue1 = " & $sValue1 & @CRLF ) Next ; --- Copy element info --- ; $UIA_ValueValuePropertyId $Recycle.Bin EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 OK --- Find window/control --- $pCondition2 OK $oList1 OK --- Selection Pattern (action) Object --- $oSelectionPattern1 OK --- Selection Pattern (action) Methods --- $oSelectionPattern1.GetCurrentSelection() --- Code Snippets --- $iLength1 = 5 --- Code Snippets --- $sValue1 = UIItem $sValue1 = $Recycle.Bin $sValue1 = UIItem $sValue1 = Config.Msi $sValue1 = UIItem $sValue1 = Documents and Settings $sValue1 = UIItem $sValue1 = Intel $sValue1 = UIItem $sValue1 = MSOCache Remarks Note the loop in bottom of the code that's used to traverse the UI Automation element array to get information about the individual elements. The $UIA_ValueValuePropertyId is copied in UIASpy from the edit element of the first selected listview item. Top of post
    1 point
  12. a small change to my _ArrayUnique2D_Ex() function that allows, by adding a parameter, to choose if the returned array must contain all of the columns of the input array or only those columns relating to the check of "Uniqueness" that is (for example): $aUniques = _ArrayUnique2D_Ex($aArray, "0,1,2,3,4,5", False) $aArray : The input array "0,1,2,3,4,5": [optional] The columns you want for "uniqueness" False/True : [optional] True (default) returns same columns as in input (reurn all columns?) False returns only the columns as in previous param Here the modified version: @boththose It seems to me that your function has a bug and a limit: 1) the bug: If you pass the following array (note the "FieldX" in middle of column3) your function does not catch it Local $aArr[7][7] = [ _ ['Field1','Field2','Field3','Field4','Field5','Field6','Result'], _ ['Field1','Field2','Field3','Field4','Field5','Field6','Result2'], _ ['Field1','Field2','Field3','Field4','Field5','Field6','Result3'], _ ['Field1','Field2','FieldX','Field4','Field5','Field6','Result4'], _ ['Field1','Field2','Field3','Field4','Field5','Field6','Result5'], _ ['Field1','Field2','Field3','Field4','Field5','Field6.1','Result6'], _ ['Field1','Field2','Field3','Field4','Field5','Field6.1','Result7']] 2) the limit: if you want to check only few columns, say 3 and 5, you can't.
    1 point
×
×
  • Create New...