MisterQuality Posted March 25, 2019 Posted March 25, 2019 How found: Mouse move (877,396) hwnd=0x00101B1E 32bit class="HwndWrapper[Register.exe;;b7352190-c3e9-4094-ac15-a0a5f9101e4c]" style=0x17080000 ex=0x40000 RuntimeId: "[7.57508.10655236]" BoundingRectangle: {l:825 t:359 r:905 b:419} ProcessId: 57508 ControlType: UIA_ButtonControlTypeId (0xC350) LocalizedControlType: "button" Name: "0" AcceleratorKey: "" AccessKey: "" HasKeyboardFocus: false IsKeyboardFocusable: true IsEnabled: true AutomationId: "" ClassName: "Button" HelpText: "" ClickablePoint: {x:865 y:389} IsControlElement: true IsContentElement: true IsPassword: false ItemType: "" IsOffscreen: false Orientation: 0 FrameworkId: "WPF" IsRequiredForForm: false ItemStatus: "" ProviderDescription: "[pid:57508,providerId:0x0 Main(parent link):Unidentified Provider (managed:MS.Internal.Automation.ElementProxy, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)]" IsDockPatternAvailable: false IsExpandCollapsePatternAvailable: false IsGridItemPatternAvailable: false IsGridPatternAvailable: false IsInvokePatternAvailable: true IsMultipleViewPatternAvailable: false IsRangeValuePatternAvailable: false IsScrollPatternAvailable: false IsScrollItemPatternAvailable: false IsSelectionItemPatternAvailable: false IsSelectionPatternAvailable: false IsTablePatternAvailable: false IsTableItemPatternAvailable: false IsTextPatternAvailable: false IsTogglePatternAvailable: false IsTransformPatternAvailable: false IsValuePatternAvailable: false IsWindowPatternAvailable: false IsItemContainerPatternAvailable: false IsVirtualizedItemPatternAvailable: false FirstChild: "0" text LastChild: "0" text Next: "Clear" button Previous: "9" button Other Props: Object has no additional properties Children: "0" text Ancestors: "" custom "Register" window "Desktop 1" pane [ No Parent ] The above information came from my Inspect tool when I mouse over the control I want to click but I am not able to identify the element. #include <MsgBoxConstants.au3> #RequireAdmin Local $registerId = Run("C:\Brink\Pos\Register.exe","C:\Brink\Pos") Sleep(30000) WinWait("[REGEXPCLASS:(?i)HwndWrapper\[Register.exe.*\]]", "", 60) ;Needed to use mouseclick in order to click on button but works on specific resolution. MouseClick("left",673,389,1) MouseClick("left",673,389,1) MouseClick("left",673,389,1) MouseClick("left",673,389,1) MouseClick("left",1244,840,1) If ProcessExists("Register.exe") Then Local $winTitle = WinGetHandle("[REGEXPCLASS:(?i)HwndWrapper\[Register.exe.*\]]") If WinActivate("[REGEXPCLASS:(?i)HwndWrapper\[Register.exe.*\]]", "") Then ControlClick($winTitle, "", "[CLASS:Button; TEXT:0]") Else MsgBox($MB_SYSTEMMODAL, "", "Window not activated") EndIf Else MsgBox($MB_SYSTEMMODAL, "", "Register is not running") EndIf I am not able to click on the button which has label 0. Not sure if there is a way around this as I tried multiple ways without success.
BrewManNH Posted March 25, 2019 Posted March 25, 2019 Use ControlClick, then you won't need the coordinates of the button, just its identification information. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
MisterQuality Posted March 25, 2019 Author Posted March 25, 2019 Sorry, I should mention the line I am having problem with. ControlClick($winTitle, "", "[CLASS:Button; TEXT:0]") The above line doesn't click on the button that has the number 0. I tried different way of identifying the object but it doesn't seem to be able to. When I use the Windows Info tool to spy the object. It is not coming back with anything. Does it mean that there is no way of interacting with this application. >>>> Window <<<< Title: Register Class: HwndWrapper[Register.exe;;b7352190-c3e9-4094-ac15-a0a5f9101e4c] Position: 0, 0 Size: 1920, 1080 Style: 0x17080000 ExStyle: 0x00040000 Handle: 0x00101B1E >>>> Control <<<< Class: Instance: ClassnameNN: Name: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: >>>> Mouse <<<< Position: 866, 392 Cursor ID: 0 Color: 0xDBDBDB >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< >>>> Hidden Text <<<<
BrewManNH Posted March 25, 2019 Posted March 25, 2019 You can try this set of UDFs to try and access this program. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
LarsJ Posted March 25, 2019 Posted March 25, 2019 Try this code based on the information provided by Inspect.exe: expandcollapse popup#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 "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_ControlTypePropertyId, $UIA_WindowControlTypeId, $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Register", $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_ButtonControlTypeId, $pCondition2 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "0", $pCondition3 ) $oUIAutomation.CreateAndCondition( $pCondition2, $pCondition3, $pAndCondition3 ) If Not $pAndCondition3 Then Return ConsoleWrite( "$pAndCondition3 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition3 OK" & @CRLF ) Local $pButton, $oButton $oWindow1.FindFirst( $TreeScope_Descendants, $pAndCondition3, $pButton ) $oButton = ObjCreateInterface( $pButton, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oButton ) Then Return ConsoleWrite( "$oButton ERR" & @CRLF ) ConsoleWrite( "$oButton OK" & @CRLF ) ; --- Invoke Pattern (action) Object --- ConsoleWrite( "--- Invoke Pattern (action) Object ---" & @CRLF ) Local $pInvokePattern1, $oInvokePattern1 $oButton.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 You need CUIAutomation2.au3. You can find it in the 7z-file at bottom of first post. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
MisterQuality Posted March 25, 2019 Author Posted March 25, 2019 I tried this code and it doesn't work. The spy tool also doesn't detect the application
MisterQuality Posted March 25, 2019 Author Posted March 25, 2019 I am getting the following error. >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\tranq\Downloads\SampleTest.au3" $oUIAutomation OK $oDesktop OK --- Find window/control --- $pAndCondition1 OK $oWindow1 ERR >Exit code: 0 Time: 14.75
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now