AutoIt MouseGetPos Function

The MouseGetPos function returns the X Y position of the mouse pointer.

2772 views

Edited: 2021-02-14 02:24

The AutoIt MouseGetPos function returns the current position of the mouse pointer. The returned value can either be the X and Y position, X alone or Y alone.

The MouseCoordMode Option controls whether the absolute or relative position is returned. Default is Absolute.

Here is an example that shows how to obtain the position of the pointer, and show it in a message box:

$pos = MouseGetPos()
MsgBox(0, "Mouse (x) left, (y) top:", $pos[0] & "," & $pos[1])

Parameters

This Function takes 1 optional parameter, which controls the value that should be returned.

NoneIf no parameter was provided, a 2 element array will be returned containing the x and y positions.
0Returns the (x) left position of the pointer.
1Returns the (y) top position of the pointer.

Tell us what you think:

  1. How to declare and work with variables in AutoIt, as well as some background information.
  2. Everything you need to know about working with minimized windows.
  3. How to set the request headers when performing HTTP requests.
  4. This Tutorial will focus on post requests in AutoIt, using the Winhttprequest.5.1 object.
  5. How to use while, for, and do until loops, and how to loop through arrays and object in AutoIt.

More in: AutoIt Tutorials