关注每一天新的互联网!

VB 从零开始编外挂(五)

———————————————————————————-
前边谈了模拟键盘,下面说说模拟鼠标。
———————————————————————————-
需要VB API函数:
mouse_event ←模拟一次鼠标事件
———————————————————————————-
相关API声明:
mouse_event

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_MIDDLEDOWN = &H20
Const MOUSEEVENTF_MIDDLEUP = &H40
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_ABSOLUTE = &H8000
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
———————————————————————————–
MOUSEEVENTF_LEFTDOWN'鼠标左键按下
MOUSEEVENTF_LEFTUP'鼠标松开
MOUSEEVENTF_RIGHTDOWN '鼠标右键按下
MOUSEEVENTF_RIGHTUP'鼠标右键松开
————————————————————————————
代码:
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_MIDDLEDOWN = &H20
Const MOUSEEVENTF_MIDDLEUP = &H40
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_ABSOLUTE = &H8000
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
'这里是 鼠标左键按下 和松开两个事件的组合即一次单击
mouse_event MOUSEEVENTF_LEFTDOWN or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
'模拟鼠标右键单击事件
mouse_event MOUSEEVENTF_RIGHTDOWN or MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
'两次连续的鼠标左键单击事件 构成一次鼠标双击事件
mouse_event MOUSEEVENTF_LEFTDOWN or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTDOWN or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
————————————————————————————

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址