-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcc_interval.ahk
More file actions
133 lines (109 loc) · 3.58 KB
/
cc_interval.ahk
File metadata and controls
133 lines (109 loc) · 3.58 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#Requires AutoHotkey v2.0
#SingleInstance
IntMode(*)
{
if WinExist("Random Gradient Control")
{
Reload
}
IntGui := Gui("-SysMenu", "Gradient Interval Control")
AddRowBtn := IntGui.Add("Button", "Default w75 xm+35", "Add Interval")
AddRowBtn.OnEvent("Click", AddRow)
StartBtn := IntGui.Add("Button", "yp wp x+10", "Start")
StartBtn.OnEvent("Click", StartWO)
ExitBtn := IntGui.Add("Button", "yp wp x+10", "Exit")
ExitBtn.OnEvent("Click", ExApp)
ExApp(*)
{
Reload
}
IntGui.AddText("xm+10 w110 Center", "Duration (sec)")
IntGui.AddText("yp w100 Center", "Level (0-9)")
IntGui.AddText("xm+10 w60", "Interval 1: ")
IntGui.AddEdit("yp w50 Right", )
IntGui.AddUpDown("Range0-9999 vInt1")
IntGui.AddText("yp w25 x+20", "Level ")
IntGui.AddEdit("yp w35 Right", )
IntGui.AddUpDown("Range0-9 vLev1")
IntGui.Show
AddRow(*)
{
if !IsSet(x)
static x := 2
IntGui.AddText("xm+10 w60", "Interval " x ": ")
IntGui.AddEdit("yp w50 Right", )
IntGui.AddUpDown("Range0-9999 vInt" x)
IntGui.AddText("yp w25 x+20", "Level ")
IntGui.AddEdit("yp w35 Right", )
IntGui.AddUpDown("Range0-9 vLev" x)
IntGui.Show("Autosize")
x += 1
}
StartWO(*)
{
IntLevObj := IntGui.Submit()
Count := ObjOwnPropCount(IntLevObj)
WOGui := AddRowWO(Count)
Loop Count/2
{
i := A_Index
WOGui['Int' i].Value := IntLevObj.Int%i%
WOGui['Lev' i].Value := IntLevObj.Lev%i%
}
WOExBtn := WOGui.AddButton("w80 xm+30", "Exit")
WOExBtn.OnEvent("Click", ExApp)
WOGui.Show()
Workout(Count, IntLevObj, WOGui)
}
Workout(Count, IntLevObj, WOGui)
{
Idx := 0
IdxMax := Count/2
while Idx < IdxMax
{
Idx := ++Idx
winid := WinGetID('A') ; Active window to be restored later
WinWait "SYSTM"
WinActivate ;"SYSTM" ; Bring SYSTM to front
ControlSend IntLevObj.Lev%Idx%, , "SYSTM" ; Send Level to SYSTM
;MsgBox(IntLevObj.Lev%Idx%)
WinActivate(winid) ; Restore previous window
; Send interval time to countdown timer
TimeLeft := IntLevObj.Int%Idx%
Timer(TimeLeft, Idx)
Timer(x, y) ; countdown timer
{
SetTimer countdown, 1000
countdown()
{
if x = 4
{
SoundPlay "timer.wav", 0
}
if x > 0
{
; decrement gui timer display
x -= 1
WOGui['Int' y].Value := x
}
}
}
Sleep IntLevObj.Int%Idx% * 1000 ; Interval length determined by Sleep time
}
MsgBox("Workout Ended")
ExApp
}
AddRowWO(Count)
{
WOGui := Gui("-SysMenu", "Gradient Interval Control")
Loop Count/2
{
i := A_Index
WOGui.AddText("xm+10 w60 Right", "Interval " i ": ")
WOGui.AddText("yp w25 Right vInt" i, )
WOGui.AddText("yp w35 x+20 Right", "Level : ")
WOGui.AddText("yp w35 Right vLev" i, )
}
return WOGui
}
}