windows keyboard shortcut to move mouse cursor between two screens

I have a laptop with its main screen(A) and a connected one(B).

Sometimes the mouse is on one screen(B) and I want it on another screen(A), but i'm just looking at the one screen(A) where the mouse isn't. I could drag a lot and look for it seeing for it to appear on A, or if B is on I can turn my head to B to see the cursor location on it(B)..so I can see when it'll get to A as I move it, But it'd be easier if I could just with a keyboard shortcut, get the mouse cursor in the middle of my laptop screen(A).

So a key to move the cursor from one screen to the other screen to a place i'd know where it is like the center. Even a mouse movement that does it, so long as whatever the move or key is works wherever the mouse is, would be ok. Is there a way?


Use AutoHotKey, with the "CoordMode" and the "MouseMove" commands.

CoordMode:

Sets coordinate mode for various commands to be relative to either the active window or the screen.

MouseMove:

Moves the mouse cursor.

Here's an example to move it to the center of the current screen:

!z::
CoordMode, Mouse, Screen
MouseMove, (A_ScreenWidth // 2), (A_ScreenHeight // 2)
return

This script works for me:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


#SingleInstance Force ; if the script is updated, replace the one and only instance

!m::

; 80 = CM_MONITORS - which basically means - monitor count
SysGet, count, 80
if count !=2 return ; only handle duo, uno - nothing to do

CoordMode, Mouse, Screen    ; this is a must as the mouse coordinate are now relative to the whole screen (both monitors)

SysGet, mon_1, Monitor, 1
SysGet, mon_2, Monitor, 2
MouseGetPos mouse_x,mouse_y

; toggle the mouse to the middle of the other screen

if (mouse_x <= mon_1Right)
{
  new_x := mon_2Left + (mon_2Right - mon_2Left) // 2
  new_y := mon_2Top + (mon_2Bottom - mon_2Top) // 2
}
else
{
  new_x := mon_1Left + (mon_1Right - mon_1Left) // 2
  new_y := mon_1Top + (mon_1Bottom - mon_1Top) // 2
}

MouseMove, %new_x%, %new_y%
Click
return

Esc::ExitApp  ; Exit script with Escape key