VB 从零开始编外挂(五)

类别:.NET开发 点击:0 评论:0 推荐:
--------------------------------------------------------------------------------------------------------------------------------------------------------
前边谈了模拟键盘,下面说说模拟鼠标。
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要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
--------------------------------------------------------------------------------------------------------------------------------------------------------
点击给我留言
--------------------------------------------------------------------------------------------------------------------------------------------------------

本文地址:http://com.8s8s.com/it/it41822.htm