#include <IsPressedEx.au3>
Opt('MustDeclareVars', 1)
HotKeySet('{Esc}', '_Quit')
Global $fTimeOld, $fTime, $sPressed, $iRet, $iTime
AdlibRegister('_Show')
While 1
$iRet = _IsPressedEx('[:ALLKEYS:]')
If $iRet Then
$fTime = Not $fTime
If StringInStr(__KeyGetType($iRet, 0), 'mouse') Then
$sPressed = 'Mouse (' & __KeyGetType($iRet, 0) & ')'
Else
$sPressed = 'Key (' & __KeyGetType($iRet, 0) & ')'
EndIf
EndIf
If $fTimeOld <> $fTime Then
$fTimeOld = $fTime
$iTime = TimerInit()
EndIf
Sleep(10)
WEnd
Func _Show()
If $sPressed Then
ToolTip('Прошло после последнего нажатия: ' & _TimeFormat(TimerDiff($iTime)) & @LF & _
'Нажимали: ' & $sPressed, 0, 0)
EndIf
EndFunc ;==>_Show
Func _Quit()
Exit
EndFunc ;==>_Quit
Func _TimeFormat($i_Timer, $i_Flag = 0)
;$i_Flag = 0 - rus
;$i_Flag = 1 - en
Local $i_Day, $i_Hour, $i_Min, $i_Sec, $s_Format = '%.2f', _
$a_String[4][2] = [[' сек', ' sec'],[' мин', ' min'],[' час', ' h'],[' дн', ' d']]
If $i_Flag > 1 Then $i_Flag = 0
$i_Timer = $i_Timer / 1000
Select
Case $i_Timer < 60
$i_Timer = StringFormat($s_Format & $a_String[0][$i_Flag], $i_Timer)
Case $i_Timer >= 60 And $i_Timer < 3600
$i_Min = Int($i_Timer / 60)
$i_Sec = Mod($i_Timer, 60)
$i_Timer = StringFormat('%02i' & $a_String[1][$i_Flag] & ' ' & $s_Format & $a_String[0][$i_Flag], _
$i_Min, $i_Sec)
Case $i_Timer >= 3600 And $i_Timer < 86400
$i_Hour = Int($i_Timer / 3600)
$i_Min = Int(($i_Timer - 3600 * $i_Hour) / 60)
$i_Sec = Mod(($i_Timer - 3600 * $i_Hour), 60)
$i_Timer = StringFormat('%02i' & $a_String[2][$i_Flag] & ' %02i' & $a_String[1][$i_Flag] & _
' ' & $s_Format & $a_String[0][$i_Flag], $i_Hour, $i_Min, $i_Sec)
Case $i_Timer >= 86400
$i_Day = Int($i_Timer / 86400)
$i_Hour = Int(($i_Timer - $i_Day * 86400) / 3600)
$i_Min = Int(($i_Timer - ($i_Day * 86400 + $i_Hour * 3600)) / 60)
$i_Sec = Mod($i_Timer - ($i_Day * 86400 + $i_Hour * 3600), 60)
$i_Timer = StringFormat('%02i' & $a_String[3][$i_Flag] & ' %02i' & $a_String[2][$i_Flag] _
& ' %02i' & $a_String[1][$i_Flag] & _
' ' & $s_Format & $a_String[0][$i_Flag], $i_Day, $i_Hour, $i_Min, $i_Sec)
EndSelect
Return $i_Timer
EndFunc ;==>_TimeFormat