guangmin0622
|
分享:
▲
▼
哈哈哈~~ 小弟在大陸網站找到嚕!
Option Explicit 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) 'dwFlags Long,下表中標誌之一或它們的組合 'dx,dy Long,根據MOUSEEVENTF_ABSOLUTE標誌,指定x,y方向的絕對位置或相對位置 'cButtons Long,沒有使用 'dwExtraInfo Long,沒有使用 'dwFlags常數 意義
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 '模擬鼠標右鍵抬起
Private Sub Form_Load() ' 1、這裡是鼠標左鍵按下和鬆開兩個事件的組合即一次單擊: mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ' 2、模擬鼠標右鍵單擊事件: mouse_event MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 ' 3、兩次連續的鼠標左鍵單擊事件 構成一次鼠標雙擊事件: mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 End Sub
|