'How to move cursor pointer from one monitor to another, and reverse the process?

I have tried using this script down below and it does work however, after I get my cursor to another monitor I want to get back to the first monitor again, after I press the shortcut key after the first time. So basically if the cursor is on one monitor, move it to another, and after it is on the 2nd monitor, move it back to first one.

This is the script:

^Space::
  CoordMode, Mouse, Screen ; This is needed to assure that you get your mouse coordinates related to the screen, not to the window 
  MouseGetPos, MouseX, MouseY
  if( MouseX > 1920) ; 1920 is the Width of my monitor number 1
  {
    MouseMove, -A_ScreenWidth, 0, 0, R
  }
  else
  {
    MouseMove, A_ScreenWidth, 0, 0, R
  }
return


Solution 1:[1]

You need to be explicit with the function, in this case, add the plus + expressly to add the current monitor's width:

^Space::
  CoordMode, Mouse, Screen ; This is needed to assure that you get your mouse coordinates related to the screen, not to the window 
  MouseGetPos, MouseX, MouseY
  if( MouseX > 1920) ; 1920 is the Width of my monitor number 1
  {
    MouseMove, -A_ScreenWidth, 0, 0, R
  }
  else
  {
    MouseMove, +A_ScreenWidth, 0, 0, R
  }
return

which should work . . .

If not, or for more options (moving windows across different-sized monitors while scaling size and position) see fling https://www.autohotkey.com/board/topic/51956-flinging-windows-across-a-multi-monitor-system/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1