鼠标API

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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值