forked from old9/ppttimer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathppttimer.ahk
231 lines (194 loc) · 5.61 KB
/
ppttimer.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#SingleInstance force
#NoTrayIcon
pt_IniFile := A_ScriptDir "\ppttimer.ini"
iniread, startKey, %pt_IniFile%, shortcuts, startKey, F12
iniread, stopKey, %pt_IniFile%, shortcuts, stopKey, ^F12
iniread, quitKey, %pt_IniFile%, shortcuts, quitKey, #ESC
iniread, opacity, %pt_IniFile%, main, opacity, 180
iniread, fontface, %pt_IniFile%, main, fontface, 寰蒋闆呴粦
iniread, fontweight, %pt_IniFile%, main, fontweight, bold
iniread, fontsize, %pt_IniFile%, main, fontsize, 40
iniread, textColor, %pt_IniFile%, main, textcolor, 000000
iniread, AheadColor, %pt_IniFile%, main, aheadColor, 9D1000
iniread, timeoutColor, %pt_IniFile%, main, timeoutColor, FF0000
iniread, backgroundColor, %pt_IniFile%, main, backgroundColor, FFFFAA
iniread, bannerWidth, %pt_IniFile%, main, width, 300
iniread, bannerHeight, %pt_IniFile%, main, height, 70
hotkey, %startKey%, startIt
hotkey, %stopKey%, stopIt
hotkey, %quitKey%, quitIt
resetTimer()
Gui, Font, %fontweight% s%fontsize% c%textColor% textcenter, %fontface%
Gui, Font, c%textColor%
Gui, Color, %backgroundColor%
Gui Add, Text, x0 y0 h%bannerHeight% w%bannerWidth% vpt_DurationText
guicontrol, +0x200 +center, pt_DurationText
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
GuiControl, Font, pt_DurationText
xposition := A_ScreenWidth - bannerWidth
Gui +LastFound +ToolWindow +AlwaysOnTop -Caption
Gui Show, y0 h%bannerHeight% w%bannerWidth% x%xposition% , CountDown
winset,transparent, %opacity%, CountDown
Winset, ExStyle, +0x20, CountDown
pt_Gui := WinExist() ; Remember Gui window ID
isPptTimerOn := false
;isTimerOn := false
SetTimer, checkPowerpoint, 250
Return
;;; if winexsist powerpoint presetation, auto start
startTimer(){
global pt_Duration
global pt_DurationText
global CountDownTimer
SetTimer CountDownTimer, Off
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
SetTimer CountDownTimer, 1000
SetTimer CountDownTimer, on
}
resetTimer(){
global pt_Duration
global pt_PlayFinishSound
global pt_FinishSoundFile
global pt_PlayWarningSound
global pt_WarningSoundFile
global pt_Ahead
global pt_IniFile
global textColor
global backgroundColor
Gui, Font, c%textColor%
gui, color, %backgroundColor%
GuiControl, font, pt_DurationText
IniRead, pt_Duration, %pt_IniFile%, Main, Duration, % 5*60
IniRead, pt_PlayFinishSound, %pt_IniFile%, Main, PlayFinishSound, %True%
IniRead, pt_FinishSoundFile, %pt_IniFile%, Main, FinishSoundFile, %A_ScriptDir%\
IniRead, pt_PlayWarningSound, %pt_IniFile%, Main, PlayWarningSound, %True%
IniRead, pt_WarningSoundFile, %pt_IniFile%, Main, WarningSoundFile, %A_ScriptDir%\
IniRead, pt_Ahead, %pt_IniFile%, Main, Ahead, 120
;msgbox, % pt_Duration " " pt_Ahead
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
}
;restart or start manually
startIt:
resetTimer()
startTimer()
return
stopIt:
resetTimer()
SetTimer CountDownTimer, off
return
quitIt:
ExitApp
return
checkPowerpoint:
IfWinExist, ahk_class screenClass
{
if !isPptTimerOn
{
isPptTimerOn := true
resetTimer()
startTimer()
}
}
else
{
if isPptTimerOn
{
isPptTimerOn := false
resetTimer()
SetTimer CountDownTimer, off
}
}
return
/*
windIDd := WinExist("My Window")
isFullScreen := isWindowFullScreen(windIDd)
MsgBox %isFullScreen%
Return
isWindowFullScreen(WinID)
{
;checks if the specified window is full screen
;use WinExist of another means to get the Unique ID (HWND) of the desired window
if ( !WinID )
return
WinGet, style, Style, ahk_id %WinID%
; 0x800000 is WS_BORDER.
; 0x20000000 is WS_MINIMIZE.
; no border and not minimized
retVal := (style & 0x20800000) ? 0 : 1
Return, retVal
}
*/
/*
checkPdf:
IfWinExist, ahk_class AcrobatSDIWindow
{
WinGet, style, Style, A
; 0x800000 is WS_BORDER.
; 0x20000000 is WS_MINIMIZE.
; no border and not minimized
retVal := (style & 0x20800000) ? 0 : 1
}
else
{
}
return
*/
CountDownTimer:
Gui +AlwaysOnTop
pt_Duration--
if pt_Duration < 0
{
blink := !blink
if blink
{
Gui, Font, c%timeoutColor%
gui, color, %backgroundColor%
}
else
{
Gui, Font, c%backgroundColor%
gui, color, %timeoutColor%
}
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
}
else if (pt_Duration <= pt_Ahead)
{
if (pt_Duration = pt_Ahead) && pt_PlayWarningSound
Gosub PlayWarningSound
Gui, Font, c%AheadColor%
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
}
else
{
Gui, Font, c%textColor%
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
}
GuiControl, font, pt_DurationText
if pt_Duration = 0
{
if pt_PlayFinishSound
Gosub PlayFinishSound
}
SetTimer CountDownTimer, 1000
Return
PlayFinishSound:
IfExist %pt_FinishSoundFile%
SoundPlay %pt_FinishSoundFile%
Return
PlayWarningSound:
IfExist %pt_WarningSoundFile%
SoundPlay %pt_WarningSoundFile%
Return
FormatSeconds(NumberOfSeconds) ; Convert the specified number of seconds to hh:mm:ss format.
{
time = 19990101 ; *Midnight* of an arbitrary date.
if NumberOfSeconds < 0
NumberOfSeconds := -NumberOfSeconds
time += %NumberOfSeconds%, seconds
FormatTime, mmss, %time%, mm:ss
;return NumberOfSeconds//3600 ":" mmss ; This method is used to support more than 24 hours worth of sections.
return mmss ; This method is used to support more than 24 hours worth of sections.
}
GuiClose:
ExitApp
Return