在batch file中实现定时input。 (倒计时一分钟)

我正在使用Windows 8写一个batch file,我被困在执行batch file中的计时器。 我想问用户的input,并给他们一分钟input他们的input。 一旦时间一分钟,然后显示消息,如“时间结束”。 所以,时间从1秒开始,在60秒结束,或者从60秒开始到0秒。 要么工作得很好。 此外,我希望计时器显示在屏幕上的某个地方,以便他们可以看到倒计时。 另外,当计时器正在运行时,我希望用户能够input一个单词并回车。 这个程序不会让用户等待,但是一旦用户input一个单词(以先到者为准),它将一直等到时间结束。 他们input一个有效的单词之后,我想把这个单词存储在某个variables中,然后做一些类似的事情(转到VALIDWORD或者echo这是一个有效的单词!)我不知道这是否可以在batch file中使用,并且有更高级的语言使用,但我想用批处理脚本来完成这个程序。 谢谢。 以下是我的理念:

@echo off :Start color EC set /a time =60 :loop cls if %time% EQU 0 goto Timesup if %time% LEQ 60 goto CONTINUE :CONTINUE ping localhost -n 2 >nul set /a time-=1 set /p cho= Enter your word: echo Remaing Time: %time% goto loop :Timesup echo The time is over! exit 

任何想法或支持,将不胜感激。 再次感谢!

批处理文件不是为这样的任务而设计的,但是可以通过有限的方式执行某些高级管理。 下面的子程序使用choice命令获得输入键,所以不允许用Enter键结束输入,也不允许用BackSpace删除字符; 它使用01键来完成这样的任务。

 @echo off setlocal call :ReadTimedInput 60 word= echo Word read: "%word%" goto :EOF :ReadTimedInput seconds result= setlocal EnableDelayedExpansion set /A seconds=100+%1 set "letters=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" for /F %%a in ('copy /Z "%~F0" NUL') do set "CR=%%a" for /F %%a in ('echo prompt $H ^| cmd') do set "BS=%%a" echo Enter a word; press 0 to End, press 1 to Clear :clear set /P "=X!CR! !CR!" < NUL set "result=" :loop set /P "=X!BS! !CR!%seconds:~-2%: %result%" < NUL choice /C ¡10%letters% /N /CS /T 1 /D ¡ > NUL if %errorlevel% equ 1 goto tick if %errorlevel% equ 2 goto clear if %errorlevel% equ 3 echo/& goto endInput set /A char=%errorlevel%-4 set "result=%result%!letters:~%char%,1!" :tick set /A seconds-=1 if %seconds% gtr 100 goto loop echo !CR!00 set "result=Time out" :endInput endlocal & set "%2=%result%" exit /B