Skip to content

Instantly share code, notes, and snippets.

@ooker777
Last active September 26, 2018 07:26
Show Gist options
  • Save ooker777/3b2a5edacb7224ffd1f0b6ea27ca6f1b to your computer and use it in GitHub Desktop.
Save ooker777/3b2a5edacb7224ffd1f0b6ea27ca6f1b to your computer and use it in GitHub Desktop.
A simple time tracker in AutoHotkey
; ticker - A Simple Time Tracker
; track your time usage on a daily basis
#InstallKeybdHook
#InstallMouseHook
Menu, Tray, Icon, %A_WinDir%\system32\shell32.dll, 44
Menu, Tray, Tip, ticker - A Simple Time Tracker`nPress numlock to see details
SetWorkingDir, C:\Users\%A_UserName%\Documents
SetTimer, CheckTime, 60000 ; updates every 1 minute
CheckTime:
FormatTime, thedate, , dd-MM-yyyy
IniRead, dc, track.txt, %thedate%, dc, 0
IniRead, NonFocused, track.txt, %thedate%, nonfocused, 0
IniRead, IdleTime, track.txt, %thedate%, idle, 0
If (A_TimeIdlePhysical < 600000) ; 10 minutes
{
If (WinActive("ahk_class DSUI:PDFXCViewer") or WinActive("ahk_class Framework::CFrame"))
dc++
Else
NonFocused++
}
Else
IdleTime++
TotalTime := dc + NonFocused + IdleTime
IniWrite, %dc%, track.txt, %thedate%, dc
IniWrite, %NonFocused% , track.txt, %thedate%, nonfocused
IniWrite, %IdleTime% , track.txt, %thedate%, idle
IniWrite, %TotalTime% , track.txt, %thedate%, total
Return
FormatMinutes(NumberOfMinutes) ; Convert mins to hh:mm
{
Time := 19990101 ; *Midnight* of an arbitrary date
Time += %NumberOfMinutes%, minutes
FormatTime, Hmm, %Time%, H'h 'mm
Return Hmm
}
numlock::
; Gui, Add, Text,, % "Dispassionated Concentration: "
Gui, font, s15, bold
Gui, Add, Text, , % FormatMinutes(dc)
Gui, font
Gui, Add, Text,xs Y+0, % "Non Focused:" FormatMinutes(NonFocused)
. "`nIdle Time:" FormatMinutes(IdleTime)
. "`nTotal Time:" FormatMinutes(TotalTime)
Gui, -SysMenu
FormatTime, thedate, , dd/MM
Gui, Show, , Track Log - %thedate%
Keywait, Esc, D T5
Gui, Destroy
Return
@ooker777
Copy link
Author

ooker777 commented Sep 26, 2018

This is a modification from Rustingsword's script to emphasize the most important thing: the actual productivity time. The differences are:

  • English display
  • Only categorize the activities as Focused and Non-Focused. In the script, I term it as Dispassionated Concentration, because you have to feel dispassionate (or detachment) about your mental monkey in order to stop the procrastination. It is a Buddhism perspective, and related to mindfulness.
  • The focused time is large and emboldened.
  • Activation switches to NumLock

Apparently today I have spent 4 hours to write this script but only 45 minutes to read textbook. I hope once it's done this chronic situation can be reversed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment