Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- LogFileLoc := A_Desktop . "\idlemonitor-log.txt"
- LogFileIntervalSec := 10
- LogFileIdleGreaterThan := 30
- FormatTime, TimeString, d M yyy mm:hh tt
- FileAppend , `r`n%TimeString% -Start-----------------`r`n , %LogFileLoc%
- ; +MinSize300x100
- Gui, +SysMenu +Resize +MinimizeBox +Owner ; avoids a taskbar button.
- Gui, Add, Text,, Log location : %LogFileLoc%
- Gui, Add, Text,, Log interval sec: %LogFileIntervalSec% and idle > %LogFileIdleGreaterThan%
- ;Gui Add, Text,, Ctrl- c to exit
- gui, font, s14, Verdana
- Gui, Add, Text, vTimerText w250
- Gui, Show, AutoSize, Idle Monitor
- StartTime := A_TickCount
- Loop
- {
- IdleTime := FormatMilliSeconds(A_TimeIdle )
- FormatTime, TimeString, d M yyy mm:hh tt ; NOW
- ElapsedTime := A_TickCount - StartTime
- if ( A_TimeIdle >= ( LogFileIdleGreaterThan * 1000 ) && ElapsedTime >= LogFileIntervalSec * 1000 ) {
- LogLine := Format("{1}, {2}`r`n", TimeString, IdleTime )
- FileAppend , %LogLine% , %LogFileLoc%
- StartTime := A_TickCount
- }
- ;Iteration %A_Index%
- GuiControl,Text, TimerText, Idle %IdleTime%
- ;Gui, Show, AutoSize, %IdleTime% - Idle Monitor
- Sleep, 1000
- }
- GuiClose:
- ExitApp
- ;GuiEscape:
- ;ExitApp
- #IfWinActive Idle Monitor ahk_class AutoHotkeyGUI
- ^c::
- ExitApp
- #IfWinActive
- FormatMilliSeconds(NumberOfMilliSeconds)
- {
- ;MsgBox %NumberOfMilliSeconds%
- totalsecs := Round(NumberOfMilliSeconds / 1000)
- mins := totalsecs / 60
- secs := Mod(totalsecs, 60 )
- return Format("{1:01d}:{2:02} [{3}]", mins, secs, NumberOfMilliSeconds)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement