Jump to content

Best Practices, Various Methods to Click GUI Controls - PDF Document Navigation


Recommended Posts

Hi everyone,

As I have made progress as a novice in AutoIt, I have always noticed clicking various items without relying on coordinates or keystrokes has been the most tricky limitation. I have been studying UI Automation elements and how to manipulate them using AutoIt by reading several different forum posts after noticing I was unsuccessful in clicking Windows controls with ControlClick().

For this particular post, I'm trying to learn how to click tabs in a non-windows GUI (a PDF editor). Using LarsJ's UIASpy.au3, I am able to discover the tabs by UIA element and ID number. I want to be able to click through the tabs one-by-one and change the navigate the documents using the software's page number control at the bottom of the GUI.

Here is what the PDF viewer tabs look like:PDFtabs.JPG.59f3cce463061b655b13edf9be65f3cf.JPG

(software application is called Nitro Pro PDF 10)

Here is the UI Automation property reference from UIA Spy:

UIASpy1.JPG.de40a5b67324f403ea47ac573f35a758.JPG

Its ID number is 12704 according to the following property sheet in UIA Spy:

UIASpy2.thumb.JPG.7777cae280421057ea086c7ec83d38e7.JPG

 

Here is the sample code generated by the UIA Spy application:

; Create UI Automation object
Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation )
If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF )
ConsoleWrite( "$oUIAutomation OK" & @CRLF )

#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 "UIA_Constants.au3" ; Can be copied from UIASpy Includes folder
;#include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder
;#include "UIA_SafeArray.au3" ; Can be copied from UIASpy Includes folder
;#include "UIA_Variant.au3" ; Can be copied from UIASpy Includes folder

Opt( "MustDeclareVars", 1 )

Example()

Func Example()
    ; Create UI Automation object
    Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation )
    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, $dtag_IUIAutomationElement )
    If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF )
    ConsoleWrite( "$oDesktop OK" & @CRLF )
EndFunc

I have not executed this code, but I see nothing there that would initiate a click on a UIA element by specified ID or other property identifier.

Here are some other times when I've experienced trouble clicking Windows controls by ID or class:

  • clicking the zoom button on Windows Photo Viewer
  • clicking buttons for options menus
  • clicking items in the Control Panel

The quick fix in most cases is to send keystrokes or keystroke combinations as a bypass of the mouse pointer.

Is it possible to read coordinates and store them into variables and then send a click to the coordinates?

What are the cases that no clicks can be sent to a control in a GUI (if any)?

This would be a great discussion for me on a milestone issue.
Thanks very much in advance for any/all responses. I'm making good progress.

 

 

Link to comment
Share on other sites

1 hour ago, etidd said:

Best Practices, Various Methods to Click GUI Controls - PDF Document Navigation

Interesting tittle.

1 hour ago, etidd said:

Nitro Pro PDF

hmmm.

The question is: what is that do you need to get done.
If you can tell what you need to do with the PDF then maybe, you don't need to either have an application or, need to get a different one more in line with coding.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Hi, argumentum.

At startup, I want to load documents into the PDF software, click the PDF tabs, and navigate to certain places in the documents (perhaps there is a tool for bookmarking). I prefer this software over Adobe Acrobat Reader.

I mentioned that I have encountered difficulty when clicking page elements by control ID or other property.

See this bit of code:

ControlClick("---image window name---", "", "[CLASS:Photos_ButtonEx; ID:42006; INSTANCE:10]", $MOUSE_CLICK_LEFT)

It, too, fails to click a Windows control in Windows Photo Viewer (the zoom scroller).

Have you experienced a situation in which you had difficulty clicking something using AutoIt?

This is about implementing UIAutomation in AutoIt like this thread:

Using UI Automation Code in AutoIt

 

Edited by etidd
Link to comment
Share on other sites

Hi, etidd

I'm novice myself, moreover I have never worked with  UI Automation / UIA Spy, so my reply might be not that usefull, but I've got few thoughts.
Code you posted looks like a header / a template. I cant see it does anything. But i have never seen UI Automation code before.

Quote

Is it possible to read coordinates and store them into variables and then send a click to the coordinates?

Yes It is. Significant part of included GUI UDFs use this principle.
For example see _GUICtrlToolbar_ClickButton
The function ↑ does not realy send 'click' event to a control. It calculates button position, hides cursor, moves it to button rectangle, clicks and moves cursor back.
Thus it can even fail because of different dpi preferences or something like that.

Quote

What are the cases that no clicks can be sent to a control in a GUI (if any)?

Well, my experience tells me, that it is most likely the bad code problem)))
But there are other options. See ControlClick remarks.

In my understanding using ControlClick does not equal clicking. You do not move cursor etc, like in _GUICtrlToolbar_ClickButton.
You send 'click' event to some class through win dll. But you do not see the insides of a class, you do not know if it reacts this event, you do not know what selfchecks it does after receiving  event.
If controll looks like a button, swims like a button, and quacks like a button, it is actually not nessesary a button. 
Try clicking any of my buttons for example RainbowCalcGui (sory for self ad)

Edited by LKP
Link to comment
Share on other sites

Some references to google on.

You can always use click x,y which transforms most logically to low-level sendmessage events. Keybd event and.or sendinput logic.

The difficulty then is finding a logical x,y

Uiautomation is then the easiest free library of Microsoft to determine a control with x,y,h,w information.

But then it is not standardized acces to java and many other controls and you fallback to pixel finding logic like findbmp or even nowadays with more advanced AI logic that can recognize captchas. 

It's all about teaching a program to see what's on a screen and use mouse and keyboard to interact and then reach complexity on multiple input devices like multi touch screens or multiple devices. After 30 years never found 1 tool for a reasonable price to handle it all including windows and Linux.

Maybe AI will solve this coming years

Edited by junkew
Link to comment
Share on other sites

Hi LKP and junkew,

Thanks very much for your responses. We all commend junkew for his brilliant code work on the useful UIA Spy tool and other contributions.

I should have responded sooner as I have been reading threads like this one.

In that thread, you had a similar discussion. It was mentioned that an .Invoke() function had been written and included in the UIA code. This page discusses the Invoke Control Pattern and goes on to mention that an automation element is invoked by clicking or double-clicking it.

I found where unavailable properties could be displayed in UIA Spy ("Right Pane" --> "Show default and unavailable properties"), and I found this information:

$UIA_IsInvokePatternAvailablePropertyId             False (InvokePattern)

Your comments seem to amount to say that a click on a desired "TabItem" control cannot be performed with UI Automation in this case.

17 hours ago, junkew said:

You can always use click x,y which transforms most logically to low-level sendmessage events. Keybd event and.or sendinput logic.

The difficulty then is finding a logical x,y

Uiautomation is then the easiest free library of Microsoft to determine a control with x,y,h,w information.

So, is it possible to extract the bounding rectangle dimensions and/or coordinates of controls available within the UIA properties and store the values into variables and perform a mouse click at appropriate coordinates? As mentioned in your above-linked thread, this is resolution dependent (thus is why I check the screen resolution before the script starts). All I want to do is to be able to retrieve the control's coordinates and simply click it at this point.

I don't know what a sendmessage or Keybd event is or what sendinput is. Is that in your program? If I know what these events are and how to invoke them as functions in the code, this may be the solution to manipulate these seemingly foreign, incompatible controls.

17 hours ago, junkew said:

It's all about teaching a program to see what's on a screen and use mouse and keyboard to interact and then reach complexity on multiple input devices like multi touch screens or multiple devices. After 30 years never found 1 tool for a reasonable price to handle it all including windows and Linux.

This is a standard desktop without any touchscreen functionality. Hopefully, that's a baseline for compatibility with this sort of programming for automation in Windows. I seem to encounter this issue of clicking controls most frequently in my journey of learning AutoIt. I'm not even able to click files or links / libraries inside of Windows Explorer (shown as "ListItems" in UIA Spy)! After processing your comment about looking for a solution for 30 years, it sounds like I need to be less choosy and utilize most working solutions.

Edited by etidd
Link to comment
Share on other sites

Here's yet another case of targeting unfamiliar controls for mouse clicks.

See Winamp screenshot below with pointer over the maximize window button;

winampbutton.thumb.JPG.13002115d9dbb60f09a9ae43e107a8ba.JPG

 

I need to click that button (or invoke it or give focus to it) as a part of my PC startup script.

What would be an appropriate way of targeting its position and sending a click to its position as discovered beforehand by the script (and stored into a variable if necessary)? :wacko: As you know very well, there can be no static position (whereas the coordinates are the same every time) because the window may be in a different position.

This example is even more more tricky because there are no UIA elements, and there is no keyboard shortcut as set forth by the software engineers. I doubt the software is open-source and going directly through the Winamp software code would yield a sensible solution. :x Also, the following code will not work successfully as it does with several other programs:

If WinGetState("[ACTIVE]","") <> @SW_MAXIMIZE Then
    WinSetState("[ACTIVE]","",@SW_MAXIMIZE)
EndIf

I actually have an idea of what I might do to target the position of the Winamp maximize window button. I think I can use WinMove() first and then obtain the window size and yield a suitable coordinate combination by performing subtraction between the window dimensions and the screen resolution.

As you said, some AI development could become the hybrid solution that enables the script to make basic determinations about window buttons, etc. across different GUI's; however, I'm not surprised that clicking (in general) would be the major roadblock I encounter when starting my journey toward PC automation / workspace optimization.

Edited by etidd
Link to comment
Share on other sites

Try setting the double click of the title bar to maximize instead of window shade mode in WinAMP. Then send a double click to the middle top of the window. 

Unless, of course, you plan to use window shade mode.

Link to comment
Share on other sites

This WinAMP automation is intriguing to me so I'm following along and trying things just for fun.

@Nine I expanded your one liner. Assuming I got the constants correct..

#include <SendMessage.au3>
Opt("WinTitleMatchMode", -2)

Const $WM_SYSCOMMAND = 0x0112
Const $SC_MAXIMIZE = 0xF030

$hWnd = WinGetHandle ( "Winamp 5" )

_SendMessage ($hWnd, $WM_SYSCOMMAND, $SC_MAXIMIZE, 0)

The results? It definitely makes the window full screen sized but at the windows current location ( ! ). And it works only once per launch of WinAMP.

I got a good laugh out of it. Good luck @etidd!

Link to comment
Share on other sites

Sendmessage sendinput and keybd_event you can google and are lowest way of simulating keyboard and mouse. You can read faq 31 telling the most information.

Mousemove and mouseclick are then the lowest functions to move and click.

https://www.autoitscript.com/autoit3/docs/functions/MouseMove.htm

The harder it is to identify your controls with spying tools the more creative you have to be to get an x y to move to. There are dozens of discussions on hard to get controls but then you first have to share main window spy information so high-level the technology can be determined where the program is written in.

 

Link to comment
Share on other sites

@Andreik the behavior is peculiar. After running the script, the maximize button still maximized the window, instead of restoring it. After maximizing with the button, restore did restore but a full sized window. Resizing and re-running the script did nothing until winAMP was relaunched. 
 

After running the script to maximize, I could drag from the “docked” window position and it restored the original size but rerunning the script didn’t do anything until winAMP was quit and relaunched. 

Link to comment
Share on other sites

Truly brilliant, rsn. :king: I'm so glad I presented this case study of Winamp 5.9.2. I have at least 2 or 3 other controls, including Windows controls in file Explorer, that I want to target in my next posts. It's all about creativity in manipulating various elements and controls in applications you are trying to automate using AutoIt.

Yes, the above code snippet you posted does the task of maximizing the Winamp window, but as you said, the window doesn't align properly at coordinates 0,0. For some reason, suppose the GUI is developed in a language that isn't fully compatible with Win7 (you can't inspect any elements using any spy tool.), it is positioned in an odd way as such:

Capture.JPG.311ae073bca1150f22a7520c85b88c98.JPG

8 hours ago, Andreik said:

How many times you can maximize a window? Or it doesn't work anymore after a restore?

You can do rsn's code above as many times as you like as long as Winamp is restarted once per script run, but I came up with something a little bit more simple using WinGetPos() and an arithmetic expression inside of a MouseClick() function:

If Not ProcessExists("winamp.exe") Then
    Run("C:\Program Files (x86)\Winamp\winamp.exe")
    WinWaitActive("Winamp 5.9.2 Build 10042")
    ; a special algorithm to maximize the Winamp window
    If WinGetState("[ACTIVE]","") <> @SW_MAXIMIZE Then
        Local $winampSize = WinGetPos("[ACTIVE]")
        ; TEMP DEBUGGING
        ;MsgBox(0, "Winamp Window Size & Coordinates", "X coordinate: " & $winampSize[0] & @CRLF & "Y coordinate: " & $winampSize[1] & @CRLF & "Width: " & $winampSize[2] & @CRLF & "Height: " & $winampSize[3])
        ;MsgBox(0, "Click Location", "X coordinate: " & $winampSize[2] + $winampSize[0] - 55 & @CRLF & "Y coordinate: " & $winampSize[1] + 6)
        MouseClick($MOUSE_CLICK_LEFT, $winampSize[2] + $winampSize[0] - 55, $winampSize[1] + 6)
                        ; add the width and the x-coordinate and subtract 55 and add 6 to the y-coordinate to target the maximize button
    EndIf
    Sleep(400) ; adding sleep here allows Winamp to load before the script tries to navigate the menu.
    MouseClick($MOUSE_CLICK_LEFT, 477, 323) ; have to click the artist pane because keyboard functions dont work after the window bar has been clicked
    Sleep(400)
    Send("m" & "a")
    Send("{DOWN 30}")
    Send("{UP 2}")
    Sleep(800)
    ConsoleWrite("+++ Script opened Winamp successfully. +++" & @CRLF)
Else
    ConsoleWrite("*** Winamp is already running. ***" & @CRLF)
EndIf

It works all over the screen wherever the Winamp window may be. I think it will have to do quite right! 50 points for the Monkeyboy :)

Of course, this is all dependent upon the screen resolution being 1920 x 1080 pixels. I will have to continue my work on a preliminary script that checks the desktop resolution and internet connection beforehand.

Edited by etidd
Link to comment
Share on other sites

I'm approaching the strategy of manipulating controls better.

However, the approach must be different in the original case that I posted about above regarding clicking the PDF tabs. In a creative approach, I checked to make sure I had enabled all available keyboard shortcuts. I can also set bookmarks, but it still requires automation to initiate the bookmark controls. I want things set at a proper zoom as well so I can see important documents. I did find a command of CTRL + W which will close the documents in my shut down script.

ControlViewer.au3 can only see and identify the main workspace pane within Nitro PDF, but UIA Spy can see the direct details inside of all PDF tabs and several various controls. I see $UIA_BoundingRectanglePropertyId has values of l=237,t=147,w=107,h=21.

So, do I have to make a UIA object to retrieve these 4 values for this control? Why can't I just get those values and subtract 35 from the x value in MouseClick() and be happy?

Even just being able to check the existence of the tabs as open documents as a Boolean / conditional expression will help immensely in designing this code for different cases in startup.

Edited by etidd
Link to comment
Share on other sites

Learn how the uia treewalkers work so you can navigate the tree of uia objects and then retrieve the relevant properties. The main thread in examples section on uiautomation first 10 examples will tell.

Uia Findall could be easier but can be slow if not properly used.

Uia will not work on java applications for that you have to google JAB and some experimental tryouts are around for AutoIt.

Link to comment
Share on other sites

I found an example on another one of your posts:

#include "CUIAutomation2.au3"
#include "UIAWrappers.au3"

;- Create treewalker
    $UIA_oUIAutomation.RawViewWalker($UIA_pTW)

    $oTW = ObjCreateInterface($UIA_pTW, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker)
    If IsObj($oTW) = 0 Then
        MsgBox(1, "UI automation treewalker failed", "UI Automation failed failed", 10)
    EndIf
    
  While IsObj($oUIElement) = True
    local $tName= _UIA_getPropertyValue($oUIElement, $UIA_NamePropertyId)
    Local $tHandle= Hex(_UIA_getPropertyValue($oUIElement, $UIA_NativeWindowHandlePropertyId))
    Local $tClassName= _UIA_getPropertyValue($oUIElement, $uia_classnamepropertyid)
    ; this could be adjusted to one line calling for $UIA_BoundingRectanglePropertyId, right?

Func sampleTW($t)
    ConsoleWrite("initializing tw " & $t & @CRLF)
    Local $hTimer = TimerInit()
    Local $i=0
;~ ' Lets show all the items of the desktop with a treewalker
    If $t = 1 Then $UIA_oUIAutomation.RawViewWalker($UIA_pTW)
    If $t = 2 Then $UIA_oUIAutomation.ControlViewWalker($UIA_pTW)
    If $t = 3 Then $UIA_oUIAutomation.ContentViewWalker($UIA_pTW)

    $oTW = ObjCreateInterface($UIA_pTW, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker)
    If IsObj($oTW) = 0 Then
        MsgBox(1, "UI automation treewalker failed", "UI Automation failed failed", 10)
    EndIf

    $oTW.GetFirstChildElement($UIA_oDesktop, $UIA_pUIElement)
    $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)

    While IsObj($oUIElement) = True
        ConsoleWrite($i & "Title is: " & _UIA_getPropertyValue($oUIElement, $UIA_NamePropertyId) & @TAB & "Handle=" & Hex(_UIA_getPropertyValue($oUIElement, $UIA_NativeWindowHandlePropertyId)) & @TAB & "Class=" & _UIA_getPropertyValue($oUIElement, $uia_classnamepropertyid) & @CRLF)
        $oTW.GetNextSiblingElement($oUIElement, $UIA_pUIElement)
        $oUIElement = ObjCreateInterface($UIA_pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
        $i=$i+1
    WEnd

    Local $fDiff = TimerDiff($hTimer)
    Consolewrite("Sample tw " & $t & " took: " & $fDiff & " milliseconds" & @CRLF & @CRLF)
EndFunc   ;==>sampleTW

I don't know what dependencies there are for this code to run RawViewWalker(). I'll keep reading your example work. :think:

Link to comment
Share on other sites

No over here where it started with the initial UIAWrapper libraries which was taken bij @LarsJ further in many more examples and updated interfaces from Microsoft
The UIAwrappers library can make life easier but never had the time to fix issues and improve. Some helper functions can be handy like highlight rectangle so you can see you found the area.

But be aware that UIA is not easy to learn as a starter.

  • I checked your Nitro PDF and Winamp and both are doable with UIA but can be hard and tedious.
  • The tree of WinAmp is not nicely behaving (as its hard to get with tools like inspect.exe) with UIASpy you can get tot your controls by using keys F1-F4 when you hover over certain elements and 90% can be recognized and you can generate parts of the code with UIASpy

Clicking can be done like

UIA_MouseClick( $oTreeItem1 )
ConsoleWrite( "UIA_MouseClick( $oTreeItem1 )" & @CRLF )

but you have to write code for the whole hierarchy

; --- Condition to find window/control ---

ConsoleWrite( "--- Condition to find window/control ---" & @CRLF )

Local $pCondition0
$oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Winamp v1.x", $pCondition0 )
If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF )
ConsoleWrite( "$pCondition0 OK" & @CRLF )

and then below the window you find in detail more objects 

; --- Condition to find window/control ---

ConsoleWrite( "--- Condition to find window/control ---" & @CRLF )

Local $pCondition0
$oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "1. DJ Mike Llama - Llama Whippin' Intro - Winamp [Stopped]", $pCondition0 )
If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF )
ConsoleWrite( "$pCondition0 OK" & @CRLF )

; --- Find window/control ---

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

Local $pPane1, $oPane1
$oParent.FindFirst( $TreeScope_Descendants, $pCondition0, $pPane1 )
$oPane1 = ObjCreateInterface( $pPane1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement )
If Not IsObj( $oPane1 ) Then Return ConsoleWrite( "$oPane1 ERR" & @CRLF )
ConsoleWrite( "$oPane1 OK" & @CRLF )

and reaching your control of interest

; --- Find window/control ---

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

Local $pCondition1
$oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Audio", $pCondition1 )
If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF )
ConsoleWrite( "$pCondition1 OK" & @CRLF )

Local $pTreeItem1, $oTreeItem1
$oPane1.FindFirst( $TreeScope_Descendants, $pCondition1, $pTreeItem1 )
$oTreeItem1 = ObjCreateInterface( $pTreeItem1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement )
If Not IsObj( $oTreeItem1 ) Then Return ConsoleWrite( "$oTreeItem1 ERR" & @CRLF )
ConsoleWrite( "$oTreeItem1 OK" & @CRLF )

I will clean it up a little and put the working example below later

edit: cleaned up but unfortunately not working but gives you an idea on how to set this up step by step for winamp.

#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\UIA_Constants.au3" ; Can be copied from UIASpy Includes folder
#include "includes\UIA_Functions.au3" ; Can be copied from 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

Opt( "MustDeclareVars", 1 )

Example()

Func Example()
    ; Create UI Automation object
    Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation )
    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, $dtag_IUIAutomationElement )
    If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF )
    ConsoleWrite( "$oDesktop OK" & @CRLF )

; --- Condition to find window/control ---
#Region
    Local $pCondition1
    $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Winamp v1.x", $pCondition1 )
    If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF )
    ConsoleWrite( "$pCondition1 OK" & @CRLF )

    ; --- Find window/control ---

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

    Local $pWindow, $oWindow
    $oDesktop.FindFirst( $TreeScope_Children, $pCondition1, $pWindow )
    $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement )
    If Not IsObj( $oWindow ) Then Return ConsoleWrite( "$oWindow ERR" & @CRLF )
    ConsoleWrite( "$oWindow OK" & @CRLF )
#EndRegion

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

    Local $pCondition2
    $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Audio", $pCondition2 )
    If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF )
    ConsoleWrite( "$pCondition2 OK" & @CRLF )

    Local $pTreeItem1, $oTreeItem1
    $oWindow.FindFirst($TreeScope_Descendants, $pCondition2, $pTreeItem1 )
    $oTreeItem1 = ObjCreateInterface( $pTreeItem1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement )
    If Not IsObj( $oTreeItem1 ) Then Return ConsoleWrite( "$oTreeItem1 ERR" & @CRLF )
    ConsoleWrite( "$oTreeItem1 OK" & @CRLF )

    ; --- Code Snippets ---

    ConsoleWrite( "--- Code Snippets ---" & @CRLF )
#endregion

    UIA_MouseClick( $oTreeItem1 )
    ConsoleWrite( "UIA_MouseClick( $oTreeItem1 )" & @CRLF )
EndFunc

 

Edited by junkew
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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