Jump to content
DrGert

ControlClick fails on class TSpTBXToolbar object

Recommended Posts

DrGert

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

 

Share this post


Link to post
Share on other sites
water
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
DrGert

@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

 

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
DrGert

@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

 

Share this post


Link to post
Share on other sites
DrGert

@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

 

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Danyfirex

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

Share this post


Link to post
Share on other sites
DrGert

@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

Share this post


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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.