Function Reference


_WinAPI_GetMousePos

Returns the current mouse position

#include <WinAPI.au3>
_WinAPI_GetMousePos ( [$bToClient = False [, $hWnd = 0]] )

Parameters

$bToClient [optional] If True, the coordinates will be converted to client coordinates
$hWnd [optional] Window handle used to convert coordinates if $bToClient is True

Return Value

Success: a $tagPOINT structure with current mouse position.
Failure: sets the @error flag to non-zero.

Remarks

This function takes into account the current MouseCoordMode setting when obtaining the mouse position. It
will also convert screen to client coordinates based on the parameters passed.

Related

$tagPOINT, _WinAPI_GetMousePosX, _WinAPI_GetMousePosY

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd = GUICreate("test")
    Local $tPoint = _WinAPI_GetMousePos()
    Local $tPoint2 = _WinAPI_GetMousePos(True, $hWnd)

    MsgBox($MB_SYSTEMMODAL, "Mouse Pos", _
            "X = " & DllStructGetData($tPoint, "X") & @CRLF & "Y = " & DllStructGetData($tPoint, "Y") & @CRLF & @CRLF & _
            "Client" & @CRLF & "X = " & DllStructGetData($tPoint2, "X") & @CRLF & "Y = " & DllStructGetData($tPoint2, "Y"))
EndFunc   ;==>Example