Jump to content

Why this controlclick doesn't work


lichadec
 Share

Recommended Posts

Hi, I used controlclick with coords in the past without problem but somehow I couldn't get it work today.

I am trying to click a button with this code. What happens is that it seems to click on the control (I have a way to tell it) but it doesn't click at the button I want.

ControlClick("Digital Oscilloscope", "", "[CLASS:ScrollToolbar; INSTANCE:1]", "Left", "1", 295, 11)

In the same script I have the following, controlclick without coords, which works fine.

ControlClick("Digital Oscilloscope", "", "[CLASS:ComboBox; INSTANCE:3]")

Can anyone help?

post-61208-0-87956500-1289639125_thumb.j

Link to comment
Share on other sites

Try remove the quotes from the 1 (number of clicks), so this ControlClick("Digital Oscilloscope", "", "[CLASS:ScrollToolbar; INSTANCE:1]", "Left", "1", 295, 11), looks like this, ControlClick("Digital Oscilloscope", "", "[CLASS:ScrollToolbar; INSTANCE:1]", "Left", 1, 295, 11).<br><br>Notice here, MouseClick, the 'number of clicks' parameter in example script has no quotes around it.<br>

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

Hello lichadec,

Welcome to the AutoIt Forums :graduated:

The way your script is using the pixel coords may differ from the way you obtained them.

Use 'AutoIt Window Info' tool to obtain the correct coords. it has 3 options in which to grab the coords:

1. Screen - Utilizes pixel coords based on your full screen (which is the default for which scripts search with)

2. Window - Utilizes pixel coords based on the entire window in which you are active in.

3. Client - utilizes pixel coords based on the client section of the window which you are active in.

After which you can use Opt() or AutoItSetOption() to tell your script how to use pixel coords with these examples:

Opt('PixelCoordMode',0) ;Uses pixel coords relative to the defined Window
Opt('PixelCoordMode',1) ;Uses pixel coords relative to the absolute screen coordinates
Opt('PixelCoordMode',2) ;Uses pixel coords relative to the client area fo the defined Window

AutoItSetOption('PixelCoordMode',0) ;Uses pixel coords relative to the defined Window
AutoItSetOption('PixelCoordMode',1) ;Uses pixel coords relative to the absolute screen coordinates
AutoItSetOption('PixelCoordMode',2) ;Uses pixel coords relative to the client area fo the defined Window

Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Have you tried making a relative position for the button. I know when I automated TMPEG Xpress I only had success when I used the Au3Window Info tool to get the coordinates of the button that I wanted to press relative to the Control size. This helped me when the Control Bar was sized differently on different machines. Yell if you need example

Link to comment
Share on other sites

Thanks Realm and Varian, appriciate your help!

I try all 3 PixelCoordMode but none of them works though, weird.

Varian, yes the example code will help. But I thought I AM using relative coordinates. If you look at my screenshot, (295,11) is the relative location of my target button within the target control (whose size is 881,29). Am I right?

Link to comment
Share on other sites

  • 2 weeks later...

The only thing that I can think to help you is to try MouseClick. To help you with the coordinates, use this script and browse over the button or area that you wish to be clicked. Exit the script by pressing the Escape key. The information displayed on the exiting message box will be copied to the clipboard for you to paste into a text editor so that you can use it. Just make sure that you use the correct MouseCoord option (window/client). you should also make sure that the window size remains constant...this can be handled using the WinMove() function.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=\\TEST-PC\D$\Icons\Intellipoint-010.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Created by Varian L.Styles
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/striponly
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt('PixelCoordMode', 2)
Opt('MouseCoordMode', 2)
Opt('TrayIconDebug', 1)
Opt('TrayAutoPause', 0)

#include <Misc.au3>
_Singleton(@ScriptName, 0)
ProcessSetPriority(@AutoItPID, 0)
Global $wPos, $mPos, $mClientPos, $mWindowPos, $Text, $wTitle, $Color

HotKeySet('{ESC}', '_Quit')

While 1
    Mouse_Coords()
    ;Sleep(10)
WEnd

Func _Quit()
    ToolTip('')
    $Text &= 'Mouse Position/Desktop: ' & $$mPos[0] & ',' & $$mPos[1] & @CRLF
    $Text &= 'Mouse Position/Window: ' & $mWindowPos[0] & ',' & $mWindowPos[1] & @CRLF
    $Text &= 'Mouse Position/Client: ' & $mClientPos[0] & ',' & $mClientPos[1] & @CRLF
    $wPos = WinGetPos('[ACTIVE]', '')
    $wTitle = StringLeft(WinGetTitle('[ACTIVE]', ''), 15)
    $Text &= '"' & $wTitle & '" Top-Left Coords: ' & $wPos[0] & ',' & $wPos[1] & @CRLF
    $Text &= '"' & $wTitle & '" Window Size: ' & $wPos[2] & ',' & $wPos[3] & @CRLF
    $Text &= 'Color: ' & Hex(PixelGetColor($mClientPos[0], $mClientPos[1]), 6)
    ClipPut($Text)
    MsgBox(0, 'Mouse Position Results', $Text)
    Exit
EndFunc   ;==>_Quit

Func Mouse_Coords()
    Local $String
    Opt('MouseCoordMode', 1)
    $mPos = MouseGetPos()
    Opt('MouseCoordMode', 0)
    $mWindowPos = MouseGetPos()
    Opt('MouseCoordMode', 2)
    $mClientPos = MouseGetPos()
    $Color = 'Hex Color: ' & Hex(PixelGetColor($mClientPos[0], $mClientPos[1]), 6)
    $String &= 'Window Title: ' & StringLeft(WinGetTiTle('[ACTIVE]'), 25) & @LF
    $String &= 'Desktop X: ' & $mPos[0] & ' Y: ' & $mPos[1] & @LF
    $String &= 'Window X: ' & $mWindowPos[0] & ' Y: ' & $mWindowPos[1] & @LF
    $String &= 'Client X: ' & $mClientPos[0] & ' Y: ' & $mClientPos[1] & @LF
    ToolTip($String & $Color)
EndFunc   ;==>Mouse_Coords
Edited by Varian
Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...