|
| 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 |
0 commit comments