Jaugenblick
New Member
- Joined
- Apr 12, 2002
- Messages
- 3
Is there anyway to know what the current position the cursor is?
On 2002-04-13 11:48, TsTom wrote:
Hi
I don't know which context you are looking for...
This is a windows screen cursor position.
Position 0 will be at the upper left hand corner of the screen, not the worksheet..
Ex NOT Cell A1
The only way I know how to capture the cursor location in the actual app would be to use an image box and capture the coordinates via the image's mouse move event.
Tom
Option Explicit
Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Dim z As POINTAPI ' Declare variable
Sub GetCursor()
Range("A1") = "X = "
Range("A2") = "Y = "
Do
GetCursorPos z
Range("B1") = "x: " & z.x ' Get x co-ordinets
Range("B2") = "y: " & z.y ' Get y co-ordinets
DoEvents
Loop
End Sub