MouseMove to a different monitor?

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Strahan
Posts: 10
Joined: 09 Dec 2016, 17:50
Location: Pennsylvania

MouseMove to a different monitor?

20 Jan 2019, 22:34

Hi. I sometimes lose my mouse in my triple LCD setup. I wanted a macro that will move the mouse to 100,100 on my primary LCD. I did:

Code: Select all

^+F12::
  MouseMove 100, 100
Return
and if I do CTRL-SHIFT-F12 while on my primary LCD, it's perfect. If I do it on one of the others, it moves to the same 100,100 but on that LCD. Is there any way to force it to go to the primary?
User avatar
Hellbent
Posts: 1195
Joined: 23 Sep 2017, 13:34

Re: MouseMove to a different monitor?

20 Jan 2019, 22:46

Put this at the top of your script and try again

Code: Select all

Coordmode, Mouse, Screen
https://autohotkey.com/docs/commands/CoordMode.htm
User avatar
Strahan
Posts: 10
Joined: 09 Dec 2016, 17:50
Location: Pennsylvania

Re: MouseMove to a different monitor?

21 Jan 2019, 14:46

Unfortunately, that had no effect. It still acts the same. Actually, upon closer view, it isn't doing exactly what I described after all. I had thought it was going to 100,100 just on the current monitor but when I ran it on my up top LCD it was going to 0, 100. It's like the mouse tried to move left to 100 on the far left LCD but got hung up on the "wall" since one cannot drag the mouse left off that LCD. My LCDs are arranged thus:

Image

(Yes, I'm a nerd lol). Of course, on the other hand, I just moved the mouse to the portrait LCD and tried it and it moved to actual 100, 100 but on the portrait LCD not on primary. Weird.
User avatar
Hellbent
Posts: 1195
Joined: 23 Sep 2017, 13:34

Re: MouseMove to a different monitor?

21 Jan 2019, 19:46

Try running this script on your main monitor.
Move your cursor to where you want to have your cursor sent to and then press numpad1

Code: Select all

#SingleInstance,Force
CoordMode,Mouse,Screen

*Numpad1::
	MouseGetPos,X,Y
	Msgbox, Your Cursor is at X: %X% Y: %Y%
	return
	
*Esc::ExitApp	

What does the message box say?
User avatar
Strahan
Posts: 10
Joined: 09 Dec 2016, 17:50
Location: Pennsylvania

Re: MouseMove to a different monitor?

21 Jan 2019, 19:57

It said "Your cursor is at X: 133 Y: 117". Out of curiosity, I moved it to the right LCD and did it and got "Your cursor is at X: 2028 Y: 194" then the upper, third LCD and got "Your cursor is at X: 2324 Y: -629"

PS: I just got the idea that perhaps it may get confused trying to move left but what about right? I changed my script to MouseMove 2400, -700 then tried it and now every time, no matter where my mouse is on whatever LCD, it jumps to the exact same position on the right upper LCD.

So while it isn't exactly where I'd prefer, it is accomplishing my goal of giving me somewhere to look when I can't find my mouse. Which annoyingly seems to happen often, lol. Thanks!
User avatar
Hellbent
Posts: 1195
Joined: 23 Sep 2017, 13:34

Re: MouseMove to a different monitor?

21 Jan 2019, 20:09

Strahan wrote:
21 Jan 2019, 19:57
It said "Your cursor is at X: 133 Y: 117". Out of curiosity, I moved it to the right LCD and did it and got "Your cursor is at X: 2028 Y: 194" then the upper, third LCD and got "Your cursor is at X: 2324 Y: -629"

PS: I just got the idea that perhaps it may get confused trying to move left but what about right? I changed my script to MouseMove 2400, -700 then tried it and now every time, no matter where my mouse is on whatever LCD, it jumps to the exact same position on the right upper LCD.

So while it isn't exactly where I'd prefer, it is accomplishing my goal of giving me somewhere to look when I can't find my mouse. Which annoyingly seems to happen often, lol. Thanks!


This was in the mouse move doc
MouseMove Documentation wrote:The following is an alternate way to move the mouse cursor that may work better in certain multi-monitor configurations:

DllCall("SetCursorPos", int, 100, int, 400) ; The first number is the X-coordinate and the second is the Y (relative to the screen).
Use this and try going back to 100,100
User avatar
Strahan
Posts: 10
Joined: 09 Dec 2016, 17:50
Location: Pennsylvania

Re: MouseMove to a different monitor?

22 Jan 2019, 03:46

That worked better; now I can send it to the primary LCD. Thanks again!
shawn8888
Posts: 2
Joined: 30 Dec 2019, 12:11

Re: MouseMove to a different monitor?

01 Aug 2020, 09:41

Hellbent wrote:
21 Jan 2019, 20:09
DllCall("SetCursorPos", int, 100, int, 400) ; The first number is the X-coordinate and the second is the Y (relative to the screen).
I have a 4K monitor with 150% scale and a second monitor with 100% scale. Moving the mouse to the 2nd monitor doesn't work with mousemove function, but, the DllCall function works!
Thanks!

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], paul1965 and 56 guests