VB and VBA Users Source Code: Get the position of the cursor/mouse
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Get the position of the cursor/mouse
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Thursday, March 01, 2001
Hits:
683
Category:
Windows API
Article:
The following routine returns the coordinates of the mouse/cursor. Option Explicit Private Declare Function GetCursorPos Lib "User32" (lpPoint As POINTAPI) As Long Private Type POINTAPI X As Long Y As Long End Type 'Purpose : Returns the position of the mouse pointer 'Inputs : lXPos See outputs ' lYPos See outputs 'Outputs : lXPos The horizontal coordinate from the top left ' hand side the screen to the cursor. ' lYPos The vertical coordinate from the top left ' hand side the screen to the cursor. 'Author : Andrew Baker 'Date : 14/01/2001 12:20 'Notes : 'Revisions : Sub CursorGetPosition(ByRef lXPos As Long, ByRef lYPos As Long) Dim RECT As POINTAPI Call GetCursorPos(RECT) lXPos = RECT.X lYPos = RECT.Y End Sub
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder