Mouse Coords not always the same (set/get) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
daywalker
Posts: 32
Joined: 18 Jun 2019, 01:37

Mouse Coords not always the same (set/get)

03 Jul 2020, 07:45

Hello,

With PC and 4:3 Monitor it works as it should (set and get are the same), but with Laptop and same Monitor on VGA port, i get this result:
ResultLaptop.jpg
ResultLaptop.jpg (3.48 KiB) Viewed 1647 times

Code: Select all

CoordMode, Mouse

Px:=101
Py:=101

MouseMove, %Px%, %Py%
MouseGetPos, MouseX, MouseY

msgbox Input:`n%Px%, %Px%`n`nOutput:`n%MouseX%, %MouseY%
Does anyone have an idea why?
Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Mouse Coords not always the same (set/get)

03 Jul 2020, 09:21

Hallo,
only a try:

Code: Select all

CoordMode, Mouse

Px:=101
Py:=101

DllCall("SetCursorPos", "int", Px, "int", Py)
MouseGetPos, MouseX, MouseY

msgbox Input:`n%Px%, %Px%`n`nOutput:`n%MouseX%, %MouseY%
daywalker
Posts: 32
Joined: 18 Jun 2019, 01:37

Re: Mouse Coords not always the same (set/get)

03 Jul 2020, 10:45

Thank you, this works. Is Mousemove not working 100%?


Updated the code:

Code: Select all

CoordMode, Mouse

Px:=101
Py:=101

MouseMove, %Px%, %Py%, 0
;DllCall("SetCursorPos", "int", Px, "int", Py)
sleep, -1
MouseGetPos, MouseX, MouseY

result= Input with Mousemove:`n%Px%, %Px%`n`nOutput:`n%MouseX%, %MouseY%



;MouseMove, %Px%, %Py%, 0
DllCall("SetCursorPos", "int", Px, "int", Py)
sleep, -1
MouseGetPos, MouseX, MouseY

result = %result%`n=================`nInput with DllCall:`n%Px%, %Px%`n`nOutput:`n%MouseX%, %MouseY%

msgbox %result%
Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Mouse Coords not always the same (set/get)  Topic is solved

03 Jul 2020, 11:12

So far I was satisfied with MouseMove (I'm not a gamer).
In https://www.autohotkey.com/docs/commands/MouseMove.htm
DllCall("SetCursorPos"... is pointed out as an alternative method for moving the mouse pointer,
which may work better with certain multi-monitor configurations.
daywalker
Posts: 32
Joined: 18 Jun 2019, 01:37

Re: Mouse Coords not always the same (set/get)

06 Jul 2020, 02:52

Thanks for pointing this out!!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 255 guests