2014-12-16 2 views
1

배치 파일 카운트 다운 타이머를 생성하고 싶습니다 (제한 사항으로 인해 배치 스크립트 여야 함). 지금까지 '일종의'일을하지만 자신의 단점을 가지고있는 두 개의 스크립트를 사용했습니다.시스템 시계와 동기화 된 배치 스크립트 카운트 다운 타이머를 생성해야합니다.

기준은 다음과 같습니다. 1. 시스템 시간을 xx : xx : xx 형식으로 표시해야합니다. 2. xx : xx 형식의 분 + 초 단위로 카운트 다운해야합니다. 3. 12 시간 단위 (예 : 오후 7 시부 터 7 시까 지)에서 작업 할 수 있어야합니다.

다음과 같이 카운트 다운 스크립트를 사용하고 있습니다 (내 자신이 만든 것이 아니라 특정 섹션을 수정했습니다) :

@echo off 
setlocal 

REM This script starts countdown from time you open batch file. 
REM Open at 19:00:23 and it will finish at 07:00:23 (it's range is 60 seconds) 
REM This can be checked against http://www.rechnr.com/online-calculator/how-many-hours-left-until-tomorrow-calculator.html 

:settime1 

rem Get end time 
REM for /F "tokens=1,2 delims=:" %%a in ("ResponseTime.txt") do set /A endH=10%%a%%100, endM=1%%b%%100 

REM Just for testing: 
set endH=07 
set endM=00 

title Timer 
mode con cols=20 lines=2 

:synchronize 
for /F "tokens=1,2 delims=:" %%a in ("%time%") do set /A "minutes=(endH*60+endM)-(%%a*60+1%%b-100)-1, seconds=159" 

:wait 
timeout /T 1 /NOBREAK > NUL 
echo Shift End: %minutes%:%seconds:~-2% 
set /A seconds-=1 
if %seconds% geq 100 goto wait 
set /A minutes-=1, seconds=159, minMOD5=minutes %% 5 
if %minutes% lss 0 goto :buzz 
if %minMOD5% equ 0 goto synchronize 
goto wait 

:buzz 
mode con cols=100 lines=30 
echo End of Shift 
SET /P ANSWER=Would you like to shut down the machine (Y/N)? 
echo You chose: %ANSWER% 
if /i {%ANSWER%}=={y} (goto :yes) 
if /i {%ANSWER%}=={yes} (goto :yes) 
goto :no 
:yes 
echo Shutting down 
shutdown /s /t 5 /c "Shutting down in 5 seconds" 
pause > nul 
exit /b 0 

:no 
echo You pressed no! 
pause > nul 
exit /b 1 

이 코드의 단점은 시스템 시계와 동기화되지 않으므로 동기화가되지 않으며 야간 시간대 자정 이전에는 작동하지 않는다는 것입니다.

이 문제를 해결할 수있는 도움이 되셨다면 카운트 다운을위한 동기화 변수로 시스템 클럭을 사용하는 방법이 정말 환상적 일 것입니다.

감사합니다.

답변

2

얼마 전에 순수한 일괄 처리로 작성된 다른 사람의 시계를 수정하고 알람 및 타이머와 여러 개의 "스킨"을 제공했습니다.

Clock.bat [/D] [/12] [/C] [/S:#] [/B:#] [/T:m[:s]] [/A:hh:mm] 

    /D  Set blinking dots 
    /12  Set 12 hour format 
    /C  Show calendar 
    /S:#  Set small size, from 0 to 2 (cancel /Calendar) 
    /B:#  Set brightness, from 0 to 3 
    /T:m[:s] Set timer in minutes and optional seconds 
    /A:hh:mm Set alarm time in 24 hour format (minutes in two digits) 

You may run several instances of this program to set several timers or alarms 
at different times; however, if more than one timer/alarm sounds at same time, 
this program may fail. 

To stop the buzzing alarm, press Enter. 

이것은/크기 : 카운트 타이머 1 피부, 또한 타이머가 종료 될 때 :

Clock.bat /S:1 with timer runningClock.bat /S:1 with timer buzzing

당신은 그런를 다운로드 할 수 있습니다 이것은 프로그램의 도움말 화면입니다 프로그램은 this site입니다.

+0

거의 완벽! 내가 필요로했던 것은 또한 분당 + 초 단위의 알람 시간 (예 : 07:00)까지 남은 시간을 보여주는 눈에 보이는 카운트 다운 타이머입니다. 그것을 보여주기 위해 수정할 수 있다면 100 % 완벽 할 것입니다! –

관련 문제