Get Cursor X And Y Coordinates

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 2 Labels and 1 Timer Control to your form. Set the Timer Interval property to 1.
'Insert the following code to the module :

Type POINTAPI
x As Long
y As Long
End Type
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

'Insert the following code to your form:

Dim z As POINTAPI

Private Sub Timer1_Timer()
GetCursorPos z
Label1 = "x: " & z.x
Label2 = "y: " & z.y
End Sub

Go Back