Во время зажатой мыши отправлять клики - VB
Формулировка задачи:
Народ помогите, пожалуйста!
Очень нужна такая программулинка, которая перехватывала бы нажатие левой кнопки мыши и пока она нажата, передавала 1000 кликов в минуту системе.
Решение задачи: «Во время зажатой мыши отправлять клики»
textual
Листинг программы
Option Explicit Public Type POINT X As Long Y As Long End Type Public Type MSLLHOOKSTRUCT pt As POINT mouseData As Long flags As Long time As Long dwExtraInfo As Long End Type Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private Const HC_ACTION = 0 Private Const WM_LBUTTONDOWN = &H201 Private Const WM_LBUTTONUP = &H202 Private Const WH_MOUSE_LL = &HE& Private Const LLMHF_INJECTED = 1 Private hHook As Long Public Sub StartHook() hHook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf LowLevelMouseProc, App.hInstance, 0) End Sub Public Sub StopHook() UnhookWindowsHookEx hHook End Sub Public Function LowLevelMouseProc(ByVal uCode As Long, ByVal wParam As Long, lParam As MSLLHOOKSTRUCT) As Long Dim hs As MSLLHOOKSTRUCT If uCode = HC_ACTION Then If wParam = WM_LBUTTONDOWN Then ' Нажатие CopyMemory hs, ByVal lParam, Len(hs) If Not CBool(hs.flags And LLMHF_INJECTED) Then Debug.Print "Real MouseDown" frmMain.tmrClick.Enabled = True End If ElseIf wParam = WM_LBUTTONUP Then ' Отпускание CopyMemory hs, ByVal lParam, Len(hs) If Not CBool(hs.flags And LLMHF_INJECTED) Then Debug.Print "Real MouseUp" frmMain.tmrClick.Enabled = False End If End If End If LowLevelMouseProc = CallNextHookEx(hHook, uCode, wParam, lParam) End Function
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д