Greetings,
I want the counter to plan a sound to remind me, so i modified the code as :
Code:
/*
Countdown 1.0 aka How long till I go home?
by Bekihito, WTFPL licence (http://en.wikipedia.org/wiki/WTFPL)
many thanks to the authors and contributors of http://www.autohotkey.com/forum/viewtopic.php?t=19740&highlight=countdown
for inspiration and help with this variant
*/
SetBatchLines, -1
#SingleInstance, Force
#NoEnv
SetWorkingDir , %A_ScriptDir%
XI = %A_ScreenWidth%
YI = %A_ScreenHeight%
if (FileExist("CountSet.ini")){
IniRead , XPos, CountSet.ini, Position, XPosition,
IniRead , YPos, CountSet.ini, Position, YPosition,
IniRead , Message, CountSet.ini, User, Message
IniRead , StartTime, CountSet.ini, User, StartTime
IniRead , EndTime, CountSet.ini, User, EndTime
}Else{
XPos := XI/2
YPOs := YI/2
Message = "Time to go!!!"
}
XInput := XI-250
YInput := YI-150
;On-screen display (OSD)
CustomColor = C0C0C0 ; Can be any RGB color (it will be made transparent below).
Menu ,Tray, NoStandard
Menu,Tray, Add, EndTime, SetClock
Menu,Tray, Add, Period, SetPeriod
Menu,Tray, Add,
Menu,Tray, Add, Message, SetMessage
Menu,Tray, Add,
Menu,Tray, Add, Exit, GuiClose
Gui +LastFound +AlwaysOnTop +Caption +ToolWindow +OwnDialogs
Gui, Color, %CustomColor%
Gui, Font, s10
Gui Add , Text , x0 y10 w130 h15 vpercent +Center, Time elapsed %perc% `%
Gui Add , Progress , x5 y30 w120 h10 cRed vmyprogress
Gui, Font, s16
Gui, Add, Text, x5 w120 vMyTime cRed +Center, -00:00:00
WinSet, TransColor, %CustomColor% 175 ; Make all pixels of this color transparent and make the text itself translucent (150):
SetTimer, UpdateOSD, 200 ; Causes a subroutine to be launched automatically and repeatedly at a specified time interval.
Gui, Show, x%XPos% y%YPos% w130 NoActivate, Time-to-Go ; NoActivate avoids deactivating the currently active window.
Return ; // End of Auto-Execute Section
UpdateOSD:
mysec := EndTime
EnvSub, mysec, %A_Now%, seconds
GuiControl,, MyTime, % FormatSeconds( mysec )
perc := ((StartTime-mysec)/StartTime)*100
perc := Floor(perc)
GuiControl ,,myprogress,%perc%
GuiControl ,,percent, Time elapsed %perc% `%
If (perc=100){
SetTimer, UpdateOSD, Off
GuiControl ,,percent, Done %perc% `%
SoundPlay, d:\frantic.wav
;sgBox,,Done, %Message%
}
Return
SetClock: ;Input the goal time -in my case the time I get of work,but you could type e.g. X-mass
Gui +LastFound +AlwaysOnTop +Caption +ToolWindow +OwnDialogs
WinGetPos ,XPos ,YPos,,,Time-to-Go,
InputBox , Date, Set Date ,YYYYMMDD,,160,120, %XInput%, %YInput%,,, %A_YEAR%%A_MM%%A_DD%
InputBox ,Goal ,Set EndTime,HHmm,,160 ,120, %XInput%, %YInput%,,,HHmm
Emsec = 00
StartTime = %A_Now%
EndTime = %Date%%Goal%%Emsec%
EnvSub StartTime, EndTime, seconds
StartTime := Abs(StartTime)
Goto, UpdateOSD
SetPeriod: ; Input any given time period like DDDHHmm = 0010101 = 1day 1hour 1minutes for fancy egg timer function
Gui +LastFound +AlwaysOnTop +Caption +ToolWindow +OwnDialogs
WinGetPos ,XPos ,YPos,,,Time-to-Go,
InputBox ,Period ,Set Period,DDDHHmm,,160 ,120, %XInput%, %YInput%,,,DDDHHmm
StringMid ,PeriodD, Period,1, 3
StringMid ,PeriodH, Period,4, 2
StringMid ,Periodm, Period,6, 2
Periodsec := (PeriodD*86400)+(PeriodH*3600)+(Periodm*60)
StartTime = %A_Now%
EndTime = %A_Now%
EnvAdd EndTime, Periodsec, seconds
EnvSub StartTime, EndTime, seconds
StartTime := Abs(StartTime)
Goto, UpdateOSD
SetMessage: ;Input custom message that will popup when the timer gets to 00:00:00
Gui +LastFound +AlwaysOnTop +Caption +ToolWindow +OwnDialogs
InputBox ,Message, Set Message, Custom message: ,,160 ,120, %XInput%, %YInput%,,,%Message%
Return
GuiClose: ;writes the settings into a ini file to get the position and continue count from last point (for long periods, endtimes where you had to shutdown the comp)
WinGetPos ,XPos ,YPos,,,Time-to-Go
IniWrite , %XPos%, %A_ScriptDir%\CountSet.ini, Position, XPosition
IniWrite , %YPos%, %A_ScriptDir%\CountSet.ini, Position, YPosition
IniWrite , %Message%, %A_ScriptDir%\CountSet.ini, User, Message
IniWrite , %StartTime%, %A_ScriptDir%\CountSet.ini, User, StartTime
IniWrite , %EndTime%, %A_ScriptDir%\CountSet.ini, User, EndTime
ExitApp
FormatSeconds(NumberOfSeconds) ; Convert the specified number of seconds to hh:mm:ss format.
{
time = 19990101 ; *Midnight* of an arbitrary date.
time += %NumberOfSeconds%, seconds
FormatTime, mmss, %time%, mm:ss
hours := NumberOfSeconds // 3600 ; This method is used to support more than 24 hours worth of sections.
hours := hours < 10 ? "0" . hours : hours
return hours ":" mmss
}
This works for me. You can customize the
wav sound as a crazy woman/man scream or a simple ring tone, or a beep or likewise.
Cheers
-pop