forked from RustingSword/ticker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ticker.ahk
60 lines (49 loc) · 1.79 KB
/
ticker.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
; 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