Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn ; Enable warnings to assist with detecting common errors.
  3. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  5.  
  6.  
  7.  
  8. LogFileLoc := A_Desktop . "\idlemonitor-log.txt"
  9. LogFileIntervalSec := 10
  10. LogFileIdleGreaterThan := 30
  11.  
  12.  
  13.  
  14. FormatTime, TimeString, d M yyy mm:hh tt
  15. FileAppend , `r`n%TimeString% -Start-----------------`r`n , %LogFileLoc%
  16. ; +MinSize300x100
  17.  
  18. Gui, +SysMenu +Resize +MinimizeBox +Owner ; avoids a taskbar button.
  19. Gui, Add, Text,, Log location : %LogFileLoc%
  20. Gui, Add, Text,, Log interval sec: %LogFileIntervalSec% and idle > %LogFileIdleGreaterThan%
  21. ;Gui Add, Text,, Ctrl- c to exit
  22.  
  23. gui, font, s14, Verdana
  24.  
  25. Gui, Add, Text, vTimerText w250
  26. Gui, Show, AutoSize, Idle Monitor
  27.  
  28. StartTime := A_TickCount
  29. Loop
  30. {
  31. IdleTime := FormatMilliSeconds(A_TimeIdle )
  32. FormatTime, TimeString, d M yyy mm:hh tt ; NOW
  33.  
  34. ElapsedTime := A_TickCount - StartTime
  35. if ( A_TimeIdle >= ( LogFileIdleGreaterThan * 1000 ) && ElapsedTime >= LogFileIntervalSec * 1000 ) {
  36. LogLine := Format("{1}, {2}`r`n", TimeString, IdleTime )
  37. FileAppend , %LogLine% , %LogFileLoc%
  38. StartTime := A_TickCount
  39. }
  40. ;Iteration %A_Index%
  41. GuiControl,Text, TimerText, Idle %IdleTime%
  42. ;Gui, Show, AutoSize, %IdleTime% - Idle Monitor
  43.  
  44. Sleep, 1000
  45.  
  46. }
  47.  
  48. GuiClose:
  49. ExitApp
  50.  
  51. ;GuiEscape:
  52. ;ExitApp
  53.  
  54. #IfWinActive Idle Monitor ahk_class AutoHotkeyGUI
  55. ^c::
  56. ExitApp
  57. #IfWinActive
  58.  
  59. FormatMilliSeconds(NumberOfMilliSeconds)
  60. {
  61. ;MsgBox %NumberOfMilliSeconds%
  62. totalsecs := Round(NumberOfMilliSeconds / 1000)
  63.  
  64. mins := totalsecs / 60
  65. secs := Mod(totalsecs, 60 )
  66.  
  67. return Format("{1:01d}:{2:02} [{3}]", mins, secs, NumberOfMilliSeconds)
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement