Mouse click coordinates do not match the actual

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
usnake
Posts: 9
Joined: 22 Sep 2022, 02:41

Mouse click coordinates do not match the actual

Post by usnake » 21 Nov 2022, 03:36

I used autohotkey to write an automatic script in chrome
and set the mouse coordinates based on the screen

But I need to click on the 300, 300 position
My code is

Code: Select all

MouseClick,L,300,300,,0
Occasionally, when it runs, it just clicks on the position 292,292 instead of the 300,300 I set.
What is the problem?

Rohwedder
Posts: 7774
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Mouse click coordinates do not match the actual

Post by Rohwedder » 21 Nov 2022, 04:32

Hallo,
setting mouse coordinates based on the screen did not work for some reason.
Try:

Code: Select all

CoordMode, Mouse, Screen
MouseClick,L,300,300,,0

User avatar
usnake
Posts: 9
Joined: 22 Sep 2022, 02:41

Re: Mouse click coordinates do not match the actual

Post by usnake » 21 Nov 2022, 21:26

Rohwedder wrote:
21 Nov 2022, 04:32
Hallo,
setting mouse coordinates based on the screen did not work for some reason.
Try:

Code: Select all

CoordMode, Mouse, Screen
MouseClick,L,300,300,,0
hi, I have added the following code to the top position of the script

Code: Select all

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, ToolTip, Screen
But the problem still exists, it intermittently clicks 292, 292

Rohwedder
Posts: 7774
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Mouse click coordinates do not match the actual

Post by Rohwedder » 22 Nov 2022, 03:55

Then,
try my ClickScreen:

Code: Select all

ClickScreen(300,300)

ClickScreen(x, y)
{
	Static SX := 0x10000/A_ScreenWidth, UI := "UInt"
	, SY := 0x10000/A_ScreenHeight, ME := "mouse_event"	
	DllCall(ME, UI, 0x8001, UI, Ceil(x*SX), UI, Ceil(y*SY))
	DllCall(ME, UI, 0x02), DllCall(ME, UI, 0x04)
}

Post Reply

Return to “Ask for Help (v1)”