Jump to content

ControlClick fails on class TSpTBXToolbar object


Recommended Posts

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.

ControlClick_Fail.png

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

 

Link to post
Share on other sites
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 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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 (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

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 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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 (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

@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

 

Link to post
Share on other sites

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 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.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 (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

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

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...