Gets the mouse cursor position relative to GUI window.
GUIGetCursorInfo ( [winhandle] )
| winhandle | [optional] The handle of the window to use. If omitted the "current" window will be used. |
| Success: | returns a five-element array that containing the mouse cursor information: |
| $array[0] = X coord (horizontal) | |
| $array[1] = Y coord (vertical) | |
| $array[2] = Primary down (1 if pressed, 0 if not pressed) | |
| $array[3] = Secondary down (1 if pressed, 0 if not pressed) | |
| $array[4] = ID of the control that the mouse cursor is hovering over (or 0 if none) | |
| Failure: | 0 and set @error to 1 |
#include <GUIConstantsEx.au3>
Global $x, $y
Example()
Func Example()
Local $msg
HotKeySet("{Esc}", "GetPos")
GUICreate("Press Esc to Get Pos", 400, 400)
$x = GUICtrlCreateLabel("0", 10, 10, 50)
$y = GUICtrlCreateLabel("0", 10, 30, 50)
GUISetState()
; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example
Func GetPos()
Local $a
$a = GUIGetCursorInfo()
GUICtrlSetData($x, $a[0])
GUICtrlSetData($y, $a[1])
EndFunc ;==>GetPos