是否可以运行这样的脚本:
final ints
此脚本应该一直关闭%ynum%,直到我将其关闭。 有什么方法可以一直扫描用户输入,如果用户按下让我们说“任何键”或定义的键,则转到setnum?
使用CMD可能吗?
BR
答案 0 :(得分:0)
这将无限循环,直到1.)键入秘密阶段或2.)按下Control + C(cmd.exe的默认中断信号)。
它还显示每次迭代的当前时间。它显示了您之前经历了多少次迭代/循环。第三行是秘密突破短语-随时更改。
@echo off
setlocal EnableDelayedExpansion
set "zLoopCounter=0"
set "zTestInput="
set "zLoopBreak=secr3tKey"
:zTimeWarp
cls
set "zTime=!time!"
if !zLoopCounter! GTR 0 echo ;[i] You're In A Loop. You Pressed "!zTestInput!". You've Been Here !zLoopCounter! Time^(s^) Before.
set /p zTestInput=[CurrTime !zTime!] Pick A Number:
if "!zTestInput!"=="!zLoopBreak!" (
echo ;[i] You Left The Loop!
) else (
set /a zLoopCounter+=1 >nul
goto :zTimeWarp
)
;[i] You're In A Loop. You Pressed "6". You've Been Here 1 Time(s) Before.
[CurrTime 20:12:18.21] Pick A Number:
;[i] You're In A Loop. You Pressed "98426". You've Been Here 2 Time(s) Before.
[CurrTime 20:13:13.74] Pick A Number:
;[i] You're In A Loop. You Pressed "22.2". You've Been Here 3 Time(s) Before.
[CurrTime 20:16:31.21] Pick A Number:
;[i] You're In A Loop. You Pressed "12344". You've Been Here 4 Time(s) Before.
[CurrTime 20:16:49.28] Pick A Number:
;[i] You Left The Loop