Get Mouse Position

 

The Get Mouse Position command locates the current position of the mouse cursor on the screen or window and saves the X and Y coordinates to Integer variables. This is an easy way to return the mouse cursor to its original position after a macro has completed.

 

 

Script Editor > Expand Mouse Category > Get Mouse Position

 

 

Select whether to save the mouse position relative to the screen or to the window that has focus. Then insert the variable names for saving the X and Y coordinates.

 

 

Sample Macro

This example saves the original mouse position, moves to another location and returns to the original spot.

 

1) Captures the initial position of the mouse cursor and saves the coordinates to variables N[1] and N[2].
 

2) Moves the mouse cursor to the screen coordinates of 300 and 300.
 

3) Instruct the mouse to move to coordinates N[1] and N[2], returning to its original position.

 

The delays are added to make the mouse movements visible. Without delays the movements are too quick to notice what is happening.

 

Macro Script

Get Mouse Position Screen: %N[1]%, %N[2]%

Delay 2 Seconds

Mouse Move Screen 300,300

Delay 2 Seconds

Mouse Move Screen %N[1]%, %N[2]%