#include <Misc.au3>
Local $hDLL = DllOpen("user32.dll")
While 1
Select
Case _IsPressed("01", $hDLL); Left mouse button
_MouseLog("left")
While _IsPressed("01", $hDLL)
Sleep(10)
WEnd
Case _IsPressed("02", $hDLL); Right mouse button
_MouseLog("right")
While _IsPressed("02", $hDLL)
Sleep(10)
WEnd
Case _IsPressed("04", $hDLL); Middle mouse button (three-button mouse)
_MouseLog("middle")
While _IsPressed("04", $hDLL)
Sleep(10)
WEnd
Case _IsPressed("1B", $hDLL); ESC
ExitLoop; exit...
EndSelect
Sleep(10)
WEnd
DllClose($hDLL)
Func _MouseLog($btn = "left")
Local $x, $y
$x = MouseGetPos(0)
$y = MouseGetPos(1)
ConsoleWrite(StringFormat("mouse click %s: %sX%s\r\n", $btn, $x, $y))
EndFunc ;==>_MouseLog
Если брать на примере от alex33S_K сказал(а):а как можно узнать интервал между нажатиями ?
#include <Misc.au3>
Local $hDLL = DllOpen("user32.dll")
$hTimer = TimerInit()
While 1
Select
Case _IsPressed("01", $hDLL); Left mouse button
_MouseLog("left")
While _IsPressed("01", $hDLL)
Sleep(10)
WEnd
Case _IsPressed("02", $hDLL); Right mouse button
_MouseLog("right")
While _IsPressed("02", $hDLL)
Sleep(10)
WEnd
Case _IsPressed("04", $hDLL); Middle mouse button (three-button mouse)
_MouseLog("middle")
While _IsPressed("04", $hDLL)
Sleep(10)
WEnd
Case _IsPressed("1B", $hDLL); ESC
ExitLoop; exit...
EndSelect
Sleep(10)
WEnd
DllClose($hDLL)
Func _MouseLog($btn = "left")
Local $x, $y
;TimerDiff($hTimer)
$x = MouseGetPos(0)
$y = MouseGetPos(1)
ConsoleWrite("Time " & Round(TimerDiff($hTimer)) & " M.seconds " & StringFormat("mouse click %s: %sX%s\r\n", $btn, $x, $y))
$hTimer = TimerInit()
EndFunc ;==>_MouseLog
Примерно так:S_K сказал(а):а как можно узнать интервал между нажатиями ?
#include <Misc.au3>
Global $iTimer, $iMS
Local $hDLL = DllOpen("user32.dll")
$iTimer = TimerInit(); запускаем
While 1
Select
Case _IsPressed("01", $hDLL); Left mouse button
_MouseLog("left")
While _IsPressed("01", $hDLL)
Sleep(10)
WEnd
Case _IsPressed("02", $hDLL); Right mouse button
_MouseLog("right")
While _IsPressed("02", $hDLL)
Sleep(10)
WEnd
Case _IsPressed("04", $hDLL); Middle mouse button (three-button mouse)
_MouseLog("middle")
While _IsPressed("04", $hDLL)
Sleep(10)
WEnd
Case _IsPressed("1B", $hDLL); ESC
ExitLoop; exit...
EndSelect
Sleep(10)
WEnd
DllClose($hDLL)
Func _MouseLog($btn = "left")
Local $x, $y
$x = MouseGetPos(0)
$y = MouseGetPos(1)
$iMS = Floor(TimerDiff($iTimer)); получаем округлённое значение таймера в милисекундах
$iTimer = TimerInit(); обнуляем таймер
ConsoleWrite(StringFormat("sleep: %s\r\n", $iMS))
ConsoleWrite(StringFormat("mouse click %s: %sX%s\r\n", $btn, $x, $y))
EndFunc ;==>_MouseLog
#Include <WinAPIEx.au3>
Global Const $tagMSLLHOOKSTRUCT = 'long X; long Y; dword mouseData; dword flags; dword time; ulong_ptr dwExtraInfo'
Global _
$_CbMouse = DllCallbackRegister('__MouseLowLevel', 'int', 'int;ptr;ptr'), _
$hMouseHook = _WinAPI_SetWindowsHookEx( _
$WH_MOUSE_LL, _
DllCallbackGetPtr( $_CbMouse ), _
_WinAPI_GetModuleHandle(0) _
)
OnAutoItExitRegister( '__Cleanup' )
While Sleep( 10 )
WEnd
Func __MouseLowLevel($iCode, $wParam, $lParam)
Local $Ret = _WinAPI_CallNextHookEx( $hMouseHook, $iCode, $wParam, $lParam )
; ---
If $iCode = 0 Then ;HC_ACTION
Local $tMSLLHOOK = DllStructCreate( $tagMSLLHOOKSTRUCT, $lParam )
; *
ConsoleWrite( 'Event ' & $wParam & ', pos=[' & $tMSLLHOOK.X & ',' & $tMSLLHOOK.Y & '], timestamp=' & $tMSLLHOOK.time & @CRLF)
EndIf
; ---
Return $Ret
EndFunc
Func __Cleanup()
_WinAPI_UnhookWindowsHookEx( $hMouseHook )
DllCallbackFree( $_CbMouse )
EndFunc
#include 'MouseOnEvent.au3'
HotKeySet('{ESC}', '_Quit')
_MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, '_Mouse_Events')
_MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT, '_Mouse_Events')
_MouseSetOnEvent($MOUSE_WHEELDOWN_EVENT, '_Mouse_Events')
Global $iTimer = TimerInit()
While 1
Sleep(10)
WEnd
Func _Mouse_Events($iEvent)
Switch $iEvent
Case $MOUSE_PRIMARYDOWN_EVENT
_MouseLog('Primary')
Case $MOUSE_SECONDARYDOWN_EVENT
_MouseLog('Secondary')
Case $MOUSE_WHEELDOWN_EVENT
_MouseLog('Middle')
EndSwitch
EndFunc
Func _MouseLog($sBttn)
Local $aMPos = MouseGetPos()
ConsoleWrite('Time ' & Round(TimerDiff($iTimer)) & ' M.seconds ' & StringFormat('mouse click %s: %sx%s\r\n', $sBttn, $aMPos[0], $aMPos[1]))
$iTimer = TimerInit()
EndFunc
Func _Quit()
Exit
EndFunc
#Include <WinAPIEx.au3>
Global Const _
$WM_RBUTTONDOWN = 0x0204, _
$WM_RBUTTONUP = 0x0205
Global Const $tagMSLLHOOKSTRUCT = 'long X; long Y; dword mouseData; dword flags; dword time; ulong_ptr dwExtraInfo'
Global $iTime, _
$_CbMouse = DllCallbackRegister('__MouseLowLevel', 'int', 'int;ptr;ptr'), _
$hMouseHook = _WinAPI_SetWindowsHookEx( _
$WH_MOUSE_LL, _
DllCallbackGetPtr( $_CbMouse ), _
_WinAPI_GetModuleHandle(0) _
)
OnAutoItExitRegister( '__Cleanup' )
While Sleep( 10 )
WEnd
Func __MouseLowLevel($iCode, $wParam, $lParam)
Local $Ret = _WinAPI_CallNextHookEx( $hMouseHook, $iCode, $wParam, $lParam )
; ---
If $iCode = 0 Then ;HC_ACTION
Local $tMSLLHOOK = DllStructCreate( $tagMSLLHOOKSTRUCT, $lParam )
; *
Switch $wParam
Case $WM_RBUTTONDOWN
$iTime = $tMSLLHOOK.time
Case $WM_RBUTTONUP
ConsoleWrite( ( $tMSLLHOOK.time - $iTime ) & " ms" & @CRLF)
EndSwitch
;ConsoleWrite( 'Event ' & $wParam & ', pos=[' & $tMSLLHOOK.X & ',' & $tMSLLHOOK.Y & '], timestamp=' & $tMSLLHOOK.time & @CRLF)
EndIf
; ---
Return $Ret
EndFunc
Func __Cleanup()
_WinAPI_UnhookWindowsHookEx( $hMouseHook )
DllCallbackFree( $_CbMouse )
EndFunc