MouseMove - GlitchedSouls/AHK-Guide GitHub Wiki

As it says on the tin, MouseMove moves your mouse to the x, y coordinates you set, and can be relative to your starting x, y coordinates.

MouseMove, X, Y , Speed, Relative

Moving to a specific x, y coordinate.

To move your mouse to the top left corner of the active window / client / screen (outcome relies on CoordMode) to the coordinates x = 200, y = 200.

MouseMove, 200, 200

Moving the mouse right, 50 pixels from my original starting position.

You can do this two ways:

  1. Performing a relative movement from the starting position, right 50 pixels (to move left, you would use -50).

    MouseMove, +50, 0, , R
    
  2. Finding the original coordinates, such as x = 200, y = 200 and adding 50 to the x value.

    MouseMove, 250, 200
    

Moving to a specific x, y coordinate instantly, or extremely slowly.

The Speed parameter, which can be a variable, allows you to set the movement speed of the mouse.

To move your mouse to the coordinates x = 200, y = 200 instantly.

MouseMove, 200, 200, 0

To move your mouse to the coordinates x = 200, y = 200 extremely slow.

MouseMove, 200, 200, 100

Test yourself.

Create a script using the ScriptingSkeleton.ahk and do the following with MouseMove:

  1. Move to x = 150, y = 340
  2. Move instantly to x = 500, y = 500
  3. Move relatively to the left 150 pixels, with a speed of 20.
  4. Move relatively to the right, 25 pixels, and up, 140 pixels.

If you've done that correctly, once executed, your finishing x, y positions should be: x = 375, y= 360

Further information

AHK Documentation - MouseMove