DrGert Posted November 1, 2017 Posted November 1, 2017 Hi All, I have a program that does not respond to ControlClick. I've used AutoIt v3 Window Info to capture the control info and used it verbatim in ControlClick. But the click never happens, as witnessed by no mouse movement and no program action happening. #include <FileConstants.au3> #include <MsgBoxConstants.au3> Run("C:\Program Files (x86)\RegiStax\RegiStax 6\RegiStax6.exe") Local $hRS6 = WinWaitActive("RegiStax","") Sleep(5000) ; Click Select ControlClick("RegiStax", "", "[CLASS:TSpTBXToolbar.UnicodeClass; INSTANCE:1]") Sleep(5000) ConsoleWrite("Clicked Select" & @CRLF) Exit (why is copy/paste out of SciTE into forum's 'code' giving wrong syntax coloring?) Here is a screen copy of the situation showing Window Info alive and the mouse hovering over the 'Select' button. The program's buttons don't look like the usual windows stuff. Is this a problem? The non-compressed resolution is here : http://skywatcher.space:8000/download/ControlClick_Fail.png Thanks, Gert
water Posted November 1, 2017 Posted November 1, 2017 33 minutes ago, DrGert said: The program's buttons don't look like the usual windows stuff. Is this a problem? Correct. According to the help file: Quote Note: AutoIt only works with standard Microsoft controls. Some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment! My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
DrGert Posted November 1, 2017 Author Posted November 1, 2017 @water Thanks for confirming. Would 'the only way out' be to use 'MouseClick' with XY coordinates? What experiments would you prioritize? Pointer to some good demos for that would be appreciated. Thanks, Gert
water Posted November 1, 2017 Posted November 1, 2017 Before trying anything else I would check the return value of ControlClick. Do you get 0 or 1? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Earthshine Posted November 1, 2017 Posted November 1, 2017 (edited) is this the control? http://www.silverpointdevelopment.com/sptbxlib/reference.htm Edited November 1, 2017 by Earthshine My resources are limited. You must ask the right questions
DrGert Posted November 1, 2017 Author Posted November 1, 2017 @Earthshine Nice catch. Yes this seems to be a match. The 'TSpTBXToolbar' keyword is there, too. Can we derive a fix from this observation? Thanks, Gert
DrGert Posted November 2, 2017 Author Posted November 2, 2017 @water Got console return 1 from ControlClick. (which docs indicate means 'success') But nothing happened in the program. #include <FileConstants.au3> #include <MsgBoxConstants.au3> Run("C:\Program Files (x86)\RegiStax\RegiStax 6\RegiStax6.exe") Local $hRS6 = WinWaitActive("RegiStax","") Sleep(5000) ; Click Select Local $x = ControlClick("RegiStax", "", "[CLASS:TSpTBXToolbar.UnicodeClass; INSTANCE:1]") Sleep(5000) ConsoleWrite("ControlClick=" & $x & @CRLF) Exit Console: >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "D:\Gert\Entwicklung\Autoit\RS6_02.au3" ControlClick=1 >Exit code: 0 Time: 11.74 Docs also say "Some controls will resist clicking unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlClick()." But I assume the combination of Run() and WinWaitActive() does the same. I also see the windows title bar 'active' in 'Registax'. Best, Gert
water Posted November 2, 2017 Posted November 2, 2017 Great. So at least AutoIt can see the Control. Next steps: I would now remove the Sleep statements - they are not needed. But there is a risk that another application steels the focus while waiting. I would add a WinActivate - just to be sure Play with the x and y coordinates. By default ControlClick clicks at the center of the Control. #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; Start RegiStax6 $iReturnValue = Run("C:\Program Files (x86)\RegiStax\RegiStax 6\RegiStax6.exe") If @error Then Exit MsgBox($MB_ICONERROR, "RegiStax Automation", "Failed to start Registax6.exe. @error = " & @error) ; Activate Window (wait 10 seconds) Local $hRS6 = WinWaitActive("RegiStax", "", 10) If $iReturnValue = 0 Then Exit MsgBox($MB_ICONERROR, "RegiStax Automation", "Window could not be found - timeout occurred") $iReturnValue = WinActivate($hRS6) If $iReturnValue = 0 Then Exit MsgBox($MB_ICONERROR, "RegiStax Automation", "Window could not be found or activated") ; Click Select Local $iXPosition = Default, $iYPosition = Default Local $iReturnValue = ControlClick($hRS6, "", "[CLASS:TSpTBXToolbar.UnicodeClass; INSTANCE:1]", "left", 1, $iXPosition, $iYPosition) If $iReturnValue = 0 Then Exit MsgBox($MB_ICONERROR, "RegiStax Automation", "ControlClick did not work") Else Exit MsgBox($MB_ICONERROR, "RegiStax Automation", "ControlClick worked") EndIf Exit My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Danyfirex Posted November 2, 2017 Posted November 2, 2017 I'm no sure about what you trying to do. But I think with this you can click over Select Button Opt("MouseCoordMode",2) Local $sTitle = "RegiStax" WinActivate($sTitle) Local $hWindow=WinWaitActive($sTitle) Local $aPos=ControlGetPos($hWindow,"","TSpTBXToolbar.UnicodeClass1") MouseClick("left",$aPos[0]+30,$aPos[1]+10,1,0) Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
DrGert Posted November 3, 2017 Author Posted November 3, 2017 @Danyfirex Using the ControlGetPos in combination with MouseCoordmode 2 and MouseClick worked very well. I was able to process my data. Thanks to all who helped! Gert
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