api函数GetCursorPos可以获得鼠标光标所在的坐标。
它的语法如下
BOOL GetCursorPos( LPPOINT lpPoint )
其中参数lpPoint是一个结构,存储着鼠标光标的X、Y屏幕坐标值。
以下代码将获得鼠标光标所在的屏幕坐标:
Public Type POINTAPI X As Long Y As Long End Type Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Sub QQ1722187970() Dim p As POINTAPI GetCursorPos p MsgBox "鼠标当前的坐标为屏幕的(" & p.X & "," & p.Y & ")" End Sub
发表评论