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 macro captures the initial position of the mouse cursor and saves the coordinates to variables N[1] and N[2]. The macro then moves the mouse cursor to the screen coordinates of 300 and 300. The last command instructs the mouse to move to coordinates N[1] and N[2], returning the cursor 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]%