OnAutoItExitRegister("QUIT")
Global $dll = DllOpen("user32.dll")
$SKEY = DllCallbackRegister("FKEY", "int", "int;ptr;ptr")
$MKEY = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)
$HKEY = DllCall($dll, "hwnd", "SetWindowsHookEx", "int", 13, "ptr", DllCallbackGetPtr($SKEY), "hwnd", $MKEY[0], "dword", 0)
$SMOUSE = DllCallbackRegister("FMOUSE", "int", "int;ptr;ptr")
$MMOUSE = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)
$HMOUSE = DllCall($dll, "hwnd", "SetWindowsHookEx", "int", 14, "ptr", DllCallbackGetPtr($SMOUSE), "hwnd", $MMOUSE[0], "dword", 0)
$FPOS = True
$CURM = 0
$OLDX = 0
$OLDY = 0
$COUNTTIME = 0
$COUNTCLICK = 0
$COUNTKEY = 0
$COUNTMOVE = 0
$TIMER = TimerInit()
While Sleep(100)
$COUNTTIME = Floor(TimerDiff($TIMER) / 1000)
TrayTip("Фараон", "T:" & $COUNTTIME & " C:" & $COUNTCLICK & " K:" & $COUNTKEY & " M:" & $COUNTMOVE, 1)
WEnd
Func FKEY($nCode, $wParam, $lParam)
If $nCode >= 0 And $wParam = 0x0100 Then
$COUNTKEY += 1
EndIf
Return DllCall($dll, "long", "CallNextHookEx", "hwnd", $HKEY[0], "int", $nCode, "ptr", $wParam, "ptr", $lParam)
EndFunc ;==>FKEY
Func FMOUSE($nCode, $wParam, $lParam)
If $nCode >= 0 Then
Switch $wParam
Case 0x0200 ; $WM_MOUSEMOVE
; начало добавленого
Local $sRect = DllStructCreate("Int[2]", $lParam), _
$CURX = DllStructGetData($sRect, 1, 1), _
$CURY = DllStructGetData($sRect, 1, 2)
; конец добавленого
If $FPOS Then
$FPOS = False
Else
$CURM += Floor(Sqrt(($OLDX - $CURX)^2 + ($OLDY - $CURY)^2))
EndIf
$OLDX = $CURX
$OLDY = $CURY
$COUNTMOVE = Floor($CURM / 96 * 2.54)
Case 0x0201, 0x0204, 0x0207 ; WM_LBUTTONDOWN, WM_RBUTTONDOWN, WM_MBUTTONDOWN
$COUNTCLICK += 1
EndSwitch
EndIf
Return DllCall($dll, "long", "CallNextHookEx", "hwnd", $HMOUSE[0], "int", $nCode, "ptr", $wParam, "ptr", $lParam)
EndFunc ;==>FMOUSE
Func QUIT()
DllCallbackFree($SKEY)
DllCall($dll, "int", "UnhookWindowsHookEx", "hwnd", $HKEY[0])
DllCallbackFree($SMOUSE)
DllCall($dll, "int", "UnhookWindowsHookEx", "hwnd", $HMOUSE[0])
DllClose($dll)
EndFunc ;==>QUIT