Skip to content

Commit bd9377b

Browse files
committed
第一版
1 parent 7bec924 commit bd9377b

File tree

3 files changed

+227
-0
lines changed

3 files changed

+227
-0
lines changed

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013 Qi Jiahui<[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

ppttimer.ahk

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
#SingleInstance force
2+
#NoTrayIcon
3+
4+
pt_IniFile := A_ScriptDir "\ppttimer.ini"
5+
6+
iniread, startKey, %pt_IniFile%, shortcuts, startKey, F12
7+
iniread, stopKey, %pt_IniFile%, shortcuts, stopKey, ^F12
8+
iniread, quitKey, %pt_IniFile%, shortcuts, quitKey, #ESC
9+
10+
iniread, opacity, %pt_IniFile%, main, opacity, 180
11+
iniread, fontface, %pt_IniFile%, main, fontface, 微软雅黑
12+
iniread, fontweight, %pt_IniFile%, main, fontweight, bold
13+
iniread, fontsize, %pt_IniFile%, main, fontsize, 40
14+
15+
iniread, textColor, %pt_IniFile%, main, textcolor, 000000
16+
iniread, AheadColor, %pt_IniFile%, main, aheadColor, 9D1000
17+
iniread, timeoutColor, %pt_IniFile%, main, timeoutColor, FF0000
18+
iniread, backgroundColor, %pt_IniFile%, main, backgroundColor, FFFFAA
19+
20+
iniread, bannerWidth, %pt_IniFile%, main, width, 300
21+
iniread, bannerHeight, %pt_IniFile%, main, height, 70
22+
23+
24+
hotkey, %startKey%, startIt
25+
hotkey, %stopKey%, stopIt
26+
hotkey, %quitKey%, quitIt
27+
28+
resetTimer()
29+
30+
Gui, Font, %fontweight% s%fontsize% c%textColor% textcenter, %fontface%
31+
Gui, Font, c%textColor%
32+
Gui, Color, %backgroundColor%
33+
Gui Add, Text, x0 y0 h%bannerHeight% w%bannerWidth% vpt_DurationText
34+
guicontrol, +0x200 +center, pt_DurationText
35+
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
36+
GuiControl, Font, pt_DurationText
37+
xposition := A_ScreenWidth - bannerWidth
38+
Gui +LastFound +ToolWindow +AlwaysOnTop -Caption
39+
Gui Show, y0 h%bannerHeight% w%bannerWidth% x%xposition% , CountDown
40+
winset,transparent, %opacity%, CountDown
41+
Winset, ExStyle, +0x20, CountDown
42+
pt_Gui := WinExist() ; Remember Gui window ID
43+
isPptTimerOn := false
44+
;isTimerOn := false
45+
SetTimer, checkPowerpoint, 250
46+
Return
47+
48+
49+
50+
;;; if winexsist powerpoint presetation, auto start
51+
startTimer(){
52+
global pt_Duration
53+
global pt_DurationText
54+
global CountDownTimer
55+
SetTimer CountDownTimer, Off
56+
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
57+
SetTimer CountDownTimer, 1000
58+
SetTimer CountDownTimer, on
59+
}
60+
61+
resetTimer(){
62+
global pt_Duration
63+
global pt_PlaySound
64+
global pt_SoundFile
65+
global pt_Ahead
66+
global pt_IniFile
67+
global textColor
68+
global backgroundColor
69+
70+
Gui, Font, c%textColor%
71+
gui, color, %backgroundColor%
72+
73+
GuiControl, font, pt_DurationText
74+
IniRead, pt_Duration, %pt_IniFile%, Main, Duration, % 5*60
75+
IniRead, pt_PlaySound, %pt_IniFile%, Main, PlaySound, %True%
76+
IniRead, pt_SoundFile, %pt_IniFile%, Main, SoundFile, %A_ScriptDir%\
77+
IniRead, pt_Ahead, %pt_IniFile%, Main, Ahead, 120
78+
;msgbox, % pt_Duration " " pt_Ahead
79+
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
80+
}
81+
82+
83+
;restart or start manually
84+
startIt:
85+
resetTimer()
86+
startTimer()
87+
return
88+
89+
90+
stopIt:
91+
resetTimer()
92+
SetTimer CountDownTimer, off
93+
return
94+
95+
quitIt:
96+
ExitApp
97+
return
98+
99+
checkPowerpoint:
100+
IfWinExist, ahk_class screenClass
101+
{
102+
if !isPptTimerOn
103+
{
104+
isPptTimerOn := true
105+
resetTimer()
106+
startTimer()
107+
}
108+
}
109+
else
110+
{
111+
if isPptTimerOn
112+
{
113+
isPptTimerOn := false
114+
resetTimer()
115+
SetTimer CountDownTimer, off
116+
}
117+
}
118+
return
119+
120+
121+
CountDownTimer:
122+
Gui +AlwaysOnTop
123+
pt_Duration--
124+
if pt_Duration < 0
125+
{
126+
blink := !blink
127+
if blink
128+
{
129+
Gui, Font, c%timeoutColor%
130+
gui, color, %backgroundColor%
131+
}
132+
else
133+
{
134+
Gui, Font, c%backgroundColor%
135+
gui, color, %timeoutColor%
136+
}
137+
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
138+
}
139+
else if (pt_Duration < pt_Ahead)
140+
{
141+
Gui, Font, c%AheadColor%
142+
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
143+
}
144+
else
145+
{
146+
Gui, Font, c%textColor%
147+
GuiControl,, pt_DurationText, % FormatSeconds(pt_Duration)
148+
}
149+
GuiControl, font, pt_DurationText
150+
if pt_Duration = 0
151+
{
152+
if pt_PlaySound
153+
Gosub PlayFinishSound
154+
}
155+
SetTimer CountDownTimer, 1000
156+
Return
157+
158+
PlayFinishSound:
159+
IfExist %pt_SoundFile%
160+
SoundPlay %pt_SoundFile%
161+
Return
162+
163+
FormatSeconds(NumberOfSeconds) ; Convert the specified number of seconds to hh:mm:ss format.
164+
{
165+
time = 19990101 ; *Midnight* of an arbitrary date.
166+
if NumberOfSeconds < 0
167+
NumberOfSeconds := -NumberOfSeconds
168+
time += %NumberOfSeconds%, seconds
169+
FormatTime, mmss, %time%, mm:ss
170+
;return NumberOfSeconds//3600 ":" mmss ; This method is used to support more than 24 hours worth of sections.
171+
return mmss ; This method is used to support more than 24 hours worth of sections.
172+
}
173+
174+
GuiClose:
175+
ExitApp
176+
Return

ppttimer.ini

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[Main]
2+
;倒计时时间
3+
Duration=4
4+
5+
;提前提醒时间,变色
6+
Ahead=2
7+
8+
;时间到时是否播放声音及声音路径
9+
PlaySound=1
10+
SoundFile=.\applause.mp3
11+
12+
;窗口样式
13+
opacity=180
14+
backgroundColor=FFFFAA
15+
fontface=微软雅黑
16+
fontweight=bold
17+
fontsize=40
18+
textcolor=000000
19+
AheadColor=9D1000
20+
timeoutColor=FF0000
21+
width=300
22+
height=70
23+
24+
25+
[shortcuts]
26+
;快捷键设置
27+
startKey=F12
28+
stopKey=^F12
29+
quitKey=#ESC
30+

0 commit comments

Comments
 (0)