Jump to content

Problem with ControlClick


Hawlong
 Share

Recommended Posts

i try to click in client area but without activating 

i use this function for test

#include <WinAPIConv.au3>
hawlong(438,177)

Func hawlong($x,$y)
    Local $hWnd = HWnd(0x00030540)
    Local $tPoint = DllStructCreate("int X;int Y")
    DllStructSetData($tPoint, "X", $x)
    DllStructSetData($tPoint, "Y", $y)
    _WinAPI_ClientToScreen($hWnd, $tPoint)
   $x1 = DllStructGetData($tPoint, "X")
   $y1 = DllStructGetData($tPoint, "Y")
   MouseClick("left", $x1, $y1)
EndFunc

The function works without problems But I want to use ControlClick

Like this 

#include <WinAPIConv.au3>
hawlong(438,177)

Func hawlong($x,$y)
    Local $hWnd = HWnd(0x00030540)
    Local $tPoint = DllStructCreate("int X;int Y")
    DllStructSetData($tPoint, "X", $x)
    DllStructSetData($tPoint, "Y", $y)
    _WinAPI_ClientToScreen($hWnd, $tPoint)
   $x1 = DllStructGetData($tPoint, "X")
   $y1 = DllStructGetData($tPoint, "Y")
   ControlClick($hWnd, "", "[CLASS:#32770; INSTANCE:1]", "left", 1, $x1, $y1)
EndFunc

The problem is that 

when i use ControlClick clicks in the wrong place

Link to comment
Share on other sites

Are the coordinates $x1 and $y1 within the bounds of the control? It's rare that you would ever need to use the x and y coordinates if you're clicking a control. MouseClick coordinates and ControlClick coordinates are completely different things, read the help file.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Not your bro, I hate that term. 

You might want to read the help file for ControlClick, if they're the same coordinates used in your MouseClick statement above, then they are not coordinates inside the bounds of the control, they might be the coordinates where the control is located, but they aren't the same thing as I stated above.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Get rid of the coordinates, as I also stated above, it's very rare that you'd need the coordinates in a ControlClick statement. They're mostly used in trying to click on a taskbar inside of a single control, or a picture element that uses coordinates of the click to determine where you clicked. Other than that, don't use them.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Link to comment
Share on other sites

17 minutes ago, Nine said:

might be a problem of relative vs absolute coords ?

No it's not.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

23 minutes ago, Hawlong said:

I want to click in an empty place where there is no button

Show us what you're trying to automate with ControlClick, we need the Summary  tab of the Au3Info tool at the very least to know what you're working with. 

A screenshot of the application and the control you're interacting with would help too.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

ok ,

this example to get x and y from client area

#include <WinAPIMisc.au3>
   $hWnd = WinGetHandle("Untitled - Paint")
    Local $iX = _WinAPI_GetMousePosX()
    Local $iX2 = _WinAPI_GetMousePosX(True, $hWnd)
    Local $iY = _WinAPI_GetMousePosY()
    Local $iY2 = _WinAPI_GetMousePosY(True, $hWnd)

    MsgBox($MB_SYSTEMMODAL, "Mouse Pos", "X = " & $iX & @CRLF & "Y = " & $iY & @CRLF & @CRLF & _
            "Client" & @CRLF & "X = " & $iX2 & @CRLF & "Y = " & $iY2)

The second example

#include <WinAPIConv.au3>
   $hWnd = WinGetHandle("Untitled - Paint")
    Local $tPoint = DllStructCreate("int X;int Y")
    DllStructSetData($tPoint, "X",259) ; x From the first example
    DllStructSetData($tPoint, "Y",528) ; y From the first example
    _WinAPI_ClientToScreen($hWnd, $tPoint)
   $x1 = DllStructGetData($tPoint, "X")
   $y1 = DllStructGetData($tPoint, "Y")
ControlClick($hWnd, "", "[CLASS:Afx:cf0000:8; INSTANCE:1]", "left", 1, $x1,$y1)

I want to click in half the black circle

 Photo from client area and Au3Info

 

2018.png

2019.png

Link to comment
Share on other sites

I ran your second script with Paint open, and it works fine. In your situation, is the paintbrush the active tool or is it still the shape tool? Because it won't show anything if the wrong tool in Paint is active. There's several brush tools that don't show anything unless they're moved, for example.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Developers

Ah... you are still screwing around with Paintbrush, like the other thread I closed.....  do you seriously think we are that thick?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

20 minutes ago, Hawlong said:

yes , the paintbrush the active tool

Then it's something on your computer, it works as designed on mine, and I'm sure everyone else's copy of "paint".

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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...