Inaccurate XY coordinates - MouseGetPos function

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
docfizzle
Posts: 37
Joined: 08 Sep 2022, 21:09

Inaccurate XY coordinates - MouseGetPos function

Post by docfizzle » 05 Oct 2022, 13:01

Hello all!

I am trying to automate some repetitive tasks.
I thought simulating mouse clicks could be a good way to go.

My current issue is that I am not getting accurate XY coordinates from the MouseGetPos function.
The XY coordinates are close but not exact.

Any ideas why I would not be getting accurate XY coordinates with the MouseGetPos function?

I am using this to get the coordinates:

Code: Select all

MouseGetPos, xpos, ypos 
MsgBox, The cursor is at X%xpos% Y%ypos%
I am on a dual monitor setup.

Thanks for your help!

RussF
Posts: 1269
Joined: 05 Aug 2021, 06:36

Re: Inaccurate XY coordinates - MouseGetPos function

Post by RussF » 05 Oct 2022, 13:06

Coordinates can be relative to the screen or the active window. See CoordMode for info on how to specify what you need.

Russ

docfizzle
Posts: 37
Joined: 08 Sep 2022, 21:09

Re: Inaccurate XY coordinates - MouseGetPos function

Post by docfizzle » 05 Oct 2022, 13:13

RussF wrote:
05 Oct 2022, 13:06
Coordinates can be relative to the screen or the active window. See CoordMode for info on how to specify what you need.

Russ
Thanks, Russ!
Great point. I'll look into that.

For a little more context, I've been keeping the window of interest in full screen on my second monitor.
Then using MouseMove and MouseClick to simulate clicks while the window.

Here is an example:

Code: Select all

MouseMove, 901, 831
Sleep, 100
mouseclick, left, 901, 831, 3
Sleep, 200
Send, ^c 

RussF
Posts: 1269
Joined: 05 Aug 2021, 06:36

Re: Inaccurate XY coordinates - MouseGetPos function

Post by RussF » 05 Oct 2022, 13:27

There is no need to move your mouse before you click and Click is preferred over MouseClick (see the docs.)

Try:

Code: Select all

Click,  901 831 3
Sleep, 200
Send, ^c
Russ

docfizzle
Posts: 37
Joined: 08 Sep 2022, 21:09

Re: Inaccurate XY coordinates - MouseGetPos function

Post by docfizzle » 05 Oct 2022, 17:14

RussF wrote:
05 Oct 2022, 13:27
There is no need to move your mouse before you click and Click is preferred over MouseClick (see the docs.)

Try:

Code: Select all

Click,  901 831 3
Sleep, 200
Send, ^c
Russ
Thanks!

Post Reply

Return to “Ask for Help (v1)”