gpt4 book ai didi

variables - 如何在 min :sec format that uses a variable as the finishing time and uses the current time as the start time? 中创建批处理文件倒数计时器

转载 作者:行者123 更新时间:2023-12-04 12:52:33 25 4
gpt4 key购买 nike

我正在尝试创建一个 min:sec 格式的倒数计时器,它使用从文本文档中获取的变量并将其用作完成时间并使用当前时间(启动 .bat 的时间)作为开始时间。目前我有这段代码可以工作并从文本文档中获取时间,但我似乎无法弄清楚如何使用它来工作。

代码:

@echo off

set CurrentTime=%time:~0,2%.%time:~3,2%

set /p StartTime=<"ResponseTime.txt"

echo.

echo %CurrentTime% %StartTIme%

echo.

最佳答案

@echo off
setlocal

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=14
set endM=58

title Timer
mode con cols=16 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 Timer: %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
pause

关于variables - 如何在 min :sec format that uses a variable as the finishing time and uses the current time as the start time? 中创建批处理文件倒数计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23102799/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com