Mouse coordinate problem when screen resolution at 3840x2160 and Window 10 scaling of 200%

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Blackbay
Posts: 1
Joined: 03 Dec 2022, 15:16

Mouse coordinate problem when screen resolution at 3840x2160 and Window 10 scaling of 200%

Post by Blackbay » 03 Dec 2022, 15:37

Hi,

I'm trying to make a mouse click hotkey sequence like the one below.
This script works, but the problem is that the mouse is not moved back to the original position the mouse where when the script was activated.

Code: Select all

+^!5:: ; Draw circle
WinActivate, Chart
MouseGetPos, posx,  posy
MouseClick, left, 4000,740
Sleep, 200
MouseClick, left, 3600, 940
MouseMove, %posx%, %posy%
return
I understand that this is probably because my screen is set to the resolution of 3840x2160 and the size of the screen is set to 200% in Window 10.
Also none of the coordinates from the Window Spy is correct with these screen resolution settings.
Can anyone point me in the right direction to solve this problem?
One solution would of course be to sett my screen to 1920x1080, but that would not work to great with my two other screens that are also set to 3840x2160.

All help would be appreciated, thanks in advance

Kim


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Mouse coordinate problem when screen resolution at 3840x2160 and Window 10 scaling of 200%

Post by mikeyww » 03 Dec 2022, 17:34

Welcome to this AutoHotkey forum!

By default, coordinates are relative to the active window. Clicking can activate a different window. Some programs use multiple windows. Therefore, subsequent clicks or moves may occur in unexpected places. To address this, you can set the CoordMode to use the screen as the point of reference for the mouse.

Explained: CoordMode

Post Reply

Return to “Ask for Help (v1)”