Instructables

Step 4: Timer

A simple timer with a built-in calculator.

@echo off
:menu 
color 0b
:bust
cls
echo Welcome to the timer. This timer only counts seconds.
echo.
echo Type in the amount of seconds to count. The number may range from 0 to   
echo 99,999. If you need help converting minutes into seconds, type c for a
echo caculator.
echo.
set/p "time=>"
if %time%==c GOTO calc
if %time%==C GOTO calc
if %time% GTR 99999 GOTO bust
cls
echo The time has been set! Press any key to start counting. You can stop the
echo timer by pressing any key. After stoping, the timer cannot continue.
echo.
pause
cls
color 0c
timeout %time%
echo.
echo (DING!)
echo.
pause
goto menu
:calc
cls
color 0a
echo Type the math problem below. This calculator doesn't accept decimals,
echo percents, etc. Only whole numbers.
echo.
set/p "math=>"
set/a nmath=%math%
cls
echo %math%=%nmath%
pause
cls
echo Would you like to return to the timer or use the calculator again?
echo.
echo c or C= calculator
echo t or T= timer
echo.
set/p "route=>"
if %route%==c GOTO calc
if %route%==C GOTO calc
if %route%==t GOTO menu
if %route%==T GOTO menu


P.S.
If anyone knows how, I'd like to know how to make some noise sound out when the timer
goes off. But only for a short time. I don't want to have it go on infinitely, because that would mean restarting the computer every time I use the timer.

 
Remove these adsRemove these ads by Signing Up
Ink Ninja1 year ago
I know that it's not exactly a ding, but using Ctrl + G in batch causes a beep of sorts.
sam577191 year ago
Type this to make the ding sound (put this after echo (DING!):

rem Making the temp file
:num
if exist temp%num%.vbs goto num
echo ' > "temp%num%.vbs"
echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "temp%num%.vbs"
echo speech.speak "Ding!" >> "temp%num%.vbs"
start temp%num%.vbs
pause
del temp%num%.vbs
pause
sam577191 year ago
if u want to make the ding sound click on the bit where it says ding & press Ctrl + Shift + G
el-xavi261 year ago
Dude you are awesome do you have a youtube account making this ?
nhepworth2 years ago
if you want to make a sound go off for a timer what you could do is have an audio recording of a DING! sound or whatever. The you could use the START command to start the audio file, then to end the sound i am sure there is a close window command. However, i do not know of it because i have never had to use it. This would make it much more difficult to get off the internet though. You would have to compact the audio file into same folder as the batch file. Possibly you could variate the locker batch file that can be found online. This batch file hides things on the desk top until it is unlocked. You could variate that into your batch file so that it requires no password and only appears for a short time. thus you would be able to call upon an audio file that, in theory, be saved to the desktop.
if you have any questions or need the locker batch file email me at noah.hepworth@hotmail.com