Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4765793
  • 博文数量: 206
  • 博客积分: 5240
  • 博客等级: 大校
  • 技术积分: 3224
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-12 21:40
文章分类

全部博文(206)

文章存档

2013年(13)

2012年(8)

2011年(33)

2010年(152)

我的朋友

分类:

2010-10-01 14:32:12

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) |
给主人留下些什么吧!~~