Page 1 of 1

how to properly fill the control click coords?

Posted: 25 Mar 2022, 08:47
by ravena1
i wanna make the script works even inactive/background and click the stop button in the app... as you can see im using the coord client from ahk window spy, but its not clicking it,

how do i fill the x and y coords correctly? do i need to use client coord from ahk window spy?


Code: Select all

SetTitleMatchMode RegEx
mywinclass:="14488"


home::
WinGet, AhkPID, PID, A
WinGetClass, mywinclass, ahk_pid %AhkPID%
SplashTextOn,,, PID:%AhkPID% ACTIVATED
Sleep 2000
SplashTextOff

sleep 500
ControlClick, x148 y587, ahk_pid %AhkPID%, , Left, 1, NA
Image

Re: how to properly fill the control click coords?

Posted: 25 Mar 2022, 08:52
by BoBo
do i need to use client coord from ahk window spy?
Why not trying it? There's even mentioned "(recommended)", so…?? :think:

Re: how to properly fill the control click coords?

Posted: 25 Mar 2022, 08:59
by ravena1
BoBo wrote:
25 Mar 2022, 08:52
do i need to use client coord from ahk window spy?
Why not trying it? There's even mentioned "(recommended)", so…?? :think:
as you can see im using the coord shown in ahk window spy, but it is not clicking the button so i assume the coords is incorrect or did i missed something?

Re: how to properly fill the control click coords?

Posted: 25 Mar 2022, 12:59
by boiler
BoBo wrote:
do i need to use client coord from ahk window spy?
Why not trying it? There's even mentioned "(recommended)", so…?? :think:
It means "recommended" when you have a choice for setting the CoordMode. Those are not to be used for ControlClick, which uses Window coordinates. In some cases, Client coordinates and Window coordinates may align so it happens to work to use them, but that would just be by coincidence. As stated in the documentation:
ControlClick documentation wrote:Specify the X and Y coordinates relative to the target window's upper left corner.
The upper left corner of a window is not where the client area of a window begins unless it happens to have no caption bar and border.

Re: how to properly fill the control click coords?

Posted: 25 Mar 2022, 13:02
by boiler
ravena1 wrote: as you can see im using the coord shown in ahk window spy, but it is not clicking the button so i assume the coords is incorrect or did i missed something?
In your window's case, the client area may be the same as the whole window, so using Client coordinates may be OK, but not every window responds to ControlClick.

Re: how to properly fill the control click coords?

Posted: 25 Mar 2022, 14:53
by ravena1
any idea how to find the coord of button? its driving me nuts

Re: how to properly fill the control click coords?

Posted: 25 Mar 2022, 14:59
by boiler
Actually, I can see even though you have mostly covered up the Window coordinates with your red line that they are different than the Client coordinates, so you are using the wrong coordinates. Use what it shows for Window coordinates. As I pointed out above, ControlClick uses Window coordinates, not Client, so on windows where they are not the same, which is most of them, do not use Client coordinates with ControlClick. Since you should be clicking about 30 pixels lower, it appears you missed the button by clicking just above it.