- @echo off
- :input
- set t=
- set t=%time%
- set str=
- set /p str=请在十秒内完成输入:
- call :time0 "%t%" "%time%" ok
- if %ok% gtr 10 (echo,输入超时,请重新输入。&goto input)
- echo,输入时间为:%ok%秒。输入内容为:%str%。
- pause
- exit
-
- :time0 计算时间差 (封装)
- @echo off&setlocal&set /a n=0&rem code 随风 @bbs.bathome.net
- for /f "tokens=1-8 delims=.: " %%a in ("%~1:%~2") do (
- set /a n+=10%%a%%100*360000+10%%b%%100*6000+10%%c%%100*100+10%%d%%100
- set /a n-=10%%e%%100*360000+10%%f%%100*6000+10%%g%%100*100+10%%h%%100)
- set /a s=n/360000,n=n%%360000,f=n/6000,n=n%%6000,m=n/100,n=n%%100
- set "ok=%s% 小时 %f% 分钟 %m% 秒 %n% 毫秒"
- set /a "ok=%s%*3600+%f%*60+%m%"
- endlocal&set %~3=%ok:-=%&goto :EOF
复制代码
[ 本帖最后由 zjw767676 于 2009-11-5 22:07 编辑 ] |