#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