Recently Browsing 0 members
No registered users viewing this page.
I wrote a script a few months ago that was working at the time. When I tried it today it wouldn't retrieve any controls. The application successfully launches, but I cannot figure out how to retrieve the control from the window that is launched. I'm on a windows 10 machine using AutoIt v22.214.171.124. The only thing I can think of that has changed is windows updates? Code is below, any help is greatly appreciated. ; Notes: ; HandleError( handleToCheck, MsgToLogOnFailure, terminateAutoItOnFail ) : function that simply checks the handle and quits AutoIt if not present ; all of this works well FileChangeDir( $CLIENT_APPLICATION_DIR ); Run( "Client.exe" ) Local $hClient = WinWaitActive( $CLIENT_TITLE, "", 10 ) $terminateOnFail = 1 HandleError( $hClient, "LaunchClient::Error: Failed to launch client. Either timed-out or failed.", $terminateOnFail ) LogToFile( "Client launched, waiting for system to ready." ) Sleep( 5000 ) ; this part does not work ; $SYSTEM_INDICATOR is a global variable. I have tried these values: "SystemIndicatorWindow" (Text), "Qt5QWindowIcon101" (ClassNN), and ; "[CLASS:Qt5QWindowIcon; INSTANCE:101]" Local $hStatusIndicator = ControlGetHandle( $hClient, "", $SYSTEM_INDICATOR ) HandleError( $hStatusIndicator, "CheckStatus::Error: couldn't retrieve control: " & $SYSTEM_INDICATOR, $terminateOnFail ) This is what the spy reveals:
Edit: I just tried this code and it works for notepad++.
FileChangeDir( "C:\Program Files\Notepad++\" ); Run( "notepad++.exe" ) Local $hNotePad = WinWaitActive( "new 1 - Notepad++", "", 10 ) If $hNotePad = 0 Or $hNotePad = -1 Then MsgBox( $MB_SYSTEMMODAL, "Error", "Error getting app handle." ) EndIf Sleep( 1000 ) Local $hNewFileBtn = ControlGetHandle( $hNotePad, "", "[CLASS:ToolbarWindow32; INSTANCE:1]" ) If $hNewFileBtn = 0 Or $hNewFileBtn = -1 Then MsgBox( $MB_SYSTEMMODAL, "Error", "Error getting button handle." ) EndIf MsgBox( $MB_SYSTEMMODAL, "Success", "Success." )
I've run into something peculiar, which I haven't been able to find more info on with the search.
The issue is a dropdownbox-control which I want to click, in a .NET program. The Class changes for everytime it is run.
When I do a normal ControlClick, nothing happens and it exits with 0.
I tried ControlClick referencing the control with [NAME:] and/or with [TEXT:] but that does not work.
However, if right before the ControlClick, I do a ControlGetHandle statement, then the ControlClick will suddenly work after all...
The window title stays the same, and there is only 1 control with that text.
ControlClick("Navigator","","[TEXT:Raster]") does not work. Returns with 0.
ControlGetHandle("Navigator","","[TEXT:Raster]") Returns with 1.
ControlClick("Navigator","","[TEXT:Raster]") works and returns with 1.
Why is this happening?
I'm glad it works, but I get the feeling I'm doing something in a wrong way.