1.变换鼠标左右键
[声 明]
Private Declare Function SwapMouseButton Lib "user32" (ByVal bSwap As Long) As Long
[示 例]
SwapMouseButton True
2.获取鼠标位置
[声 明]
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
[示 例]
Dim Pt As POINTAPI
GetCursorPos Pt
3.模拟点击鼠标
[声 明]
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
[示 例]
SetCursorPos x, y
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
4.鼠标限制在一区域内
[声 明]
Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Type RECT
left As Long
top As Long
right As Long
bottom As Long
End Type
[示 例]
Dim Rect as RECT
ClipCursor(Rect) ;限制
ClipCursor(ByVal vbNullString) ;释放
5.隐藏鼠标
[声 明]
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
[示 例]
ShowCursor True
6.设置光标
[声 明]
Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
[示 例]
SetCursor 65581
阅读(1036) | 评论(0) | 转发(0) |