-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.ahk
111 lines (91 loc) · 2.12 KB
/
timer.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#Requires AutoHotkey v2.0
#SingleInstance
A_MaxHotkeysPerInterval := 300
RunDialogue(arg)
{
ArgObj := FileOpen(".\type_shortcut_args.txt", "w")
ArgObj.Write(arg "`n0")
ArgObj.Close()
RunWait "./type_shortcut.exe"
OutputObj := FileOpen(".\type_shortcut_output.txt", "r")
Line := OutputObj.Read()
OutputObj.Close()
return Line
}
FormatTime(ms)
{
s := ms // 1000
m := s // 60
h := m // 60
s := s - m * 60
m := m - h * 60
if h < 10
h := "0" h
if m < 10
m := "0" m
if s < 10
s := "0" s
if h == 0
return m ":" s
return h ":" m ":" s
}
lastTooltip := ""
lastMouseX := 0
lastMouseY := 0
CustomTooltip(content)
{
global lastTooltip, lastMouseX, lastMouseY
mouseX := 0
mouseY := 0
MouseGetPos (&mouseX, &mouseY)
if (content != lastTooltip || lastMouseX != mouseX || lastMouseY != mouseY)
{
ToolTip(content)
lastTooltip := content
lastMouseX := mouseX
lastMouseY := mouseY
}
}
hrs := RunDialogue("hours")
if hrs == "`b" || hrs == ""
hrs := 0
hrs := Integer(hrs)
mins := RunDialogue("minutes")
if mins == "`b" || mins == ""
mins := 0
mins := Integer(mins)
secs := RunDialogue("seconds")
if secs == "`b" || secs == ""
secs := 0
secs := Integer(secs)
msTotal := (hrs*3600 + mins*60 + secs) * 1000
startTime := A_TickCount
if msTotal > 0
{
TrayTip ("Timer started for " FormatTime(msTotal) "`n[ RightCtrl/Alt+BackSpace to show time ]`n[ F24 + BackSpace to cancel ]")
while (A_TickCount - startTime) < msTotal
{
if GetKeyState("RCtrl") || (GetKeyState("Alt") && GetKeyState("BackSpace"))
{
CustomToolTip (FormatTime(msTotal - (A_TickCount - startTime)))
}
else
{
ToolTip
lastTooltip := ""
lastMouseX := 0
lastMouseY := 0
}
if GetKeyState("F24") && GetKeyState("BackSpace")
{
TrayTip
TrayTip "Timer cancelled."
ExitApp
}
}
TrayTip
TrayTip "Timer finished."
}
else
TrayTip "Timer cancelled."
ExitApp