Warp cursor across monitors with different sizes/dpis

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
anubis
Posts: 1
Joined: 10 May 2021, 20:15

Warp cursor across monitors with different sizes/dpis

10 May 2021, 20:37

Hi, I have a very peculiar setup and would like to have the cursor warp to the next monitor instead of getting stuck in against the edges of the monitor:
image.png
image.png (10.82 KiB) Viewed 316 times
Is this possible with autohotkey?

thanks
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Warp cursor across monitors with different sizes/dpis

10 May 2021, 21:37

I hope you'll find this article and script to be helpful:

Keyboard shortcuts (hotkeys) to move mouse in multi-monitor configuration - AutoHotkey Script

Be sure to read all the comments under the article (click the VIEW MORE button to see all of them). That's where the very interesting DPI-scaling discussion occurs. Regards, Joe
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Warp cursor across monitors with different sizes/dpis

23 Jun 2021, 04:20

madeup numbers, change them according to ur own resolutions!
image.png
image.png (91.99 KiB) Viewed 270 times

Code: Select all

#NoEnv
#Persistent
#SingleInstance Force
SetBatchLines -1

hHook := DllCall("SetWindowsHookEx"
		, "Int", 14 ; WH_MOUSE_LL
		, "Ptr", RegisterCallback("LowLevelMouseProc", "Fast")
		, "Ptr", 0
		, "UInt", 0
		, "Ptr")

LowLevelMouseProc(nCode, wParam, lParam) {
	x := NumGet(lParam + 0, "Int")
	y := NumGet(lParam + 4, "Int")

	switch wParam ; The identifier of the mouse message.
	{
	case 0x200: ; WM_MOUSEMOVE
		switch
		{
		case (x < 0 && y > 500): DllCall("SetCursorPos", "Int", -1, "Int", 499) ; main ->> left panel
		case (x > 1920 && y > 500): DllCall("SetCursorPos", "Int", 1921, "Int", 499) ; main ->> right panel
		case (x < 200 && y < 0): DllCall("SetCursorPos", "Int", -1, "Int", 201) ; top ->> left panel
		case (x > 1600 && y < 0): DllCall("SetCursorPos", "Int", 1921, "Int", 201) ; top ->> right panel
		}
	}

	return DllCall("CallNextHookEx", "Ptr", 0, "Int", nCode, "Ptr", wParam, "Ptr", lParam, "Ptr")
}
but u can use other general purpose software for it too
https://web.archive.org/web/20210623093438/https://superuser.com/questions/1119204/move-mouse-proportionally-between-different-resolution-and-dpi-displays
https://web.archive.org/web/20210623094028/https://github.com/dale-roberts/MouseUnSnag/
https://web.archive.org/web/20210623094136/https://superuser.com/questions/865469/how-to-make-the-mouse-wrap-from-corners-when-moving-between-monitors
https://web.archive.org/web/20210623094141/https://www.autohotkey.com/boards/viewtopic.php?t=65644#p282017

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], haomingchen1998, mikeyww, mmflume, roysubs, scriptor2016, ShatterCoder and 98 guests