批量]循环播放,直到按下某个键为止。

问题描述 投票:1回答:1

我想在这里做的是循环,直到 "x "被按下。我知道 CHOICE 随着 /T 选项。

但是 CHOICE 对我想播放的动画来说,超时时间太长了。下面是一个例子。

@echo off
cls
set frame=2
:loop
cls
type [%frame%].txt
[Here is where it would test for the keystroke.If keystroke "x" is detected,goto MENU. If not pressed within a quick second,continue.]
set /a frame=%frame%+1
goto loop

注意: 帧数是动画的,所以请记住超时时间一定要快。

loops batch-file timeout
1个回答
2
投票

这是一个古老的世界解决方案,但使用Windows certutil 来创建一个存储在批处理文件中的可执行文件--当按下空格键时,可执行文件就会退出循环。

大多数人会认为这有点冒险,因为可执行文件可以做任何事情,而且你必须盲目地相信我不会损坏你的电脑。 不过,我还是把它加在这里作为一种选择,你可以自己编译可执行文件,然后用它来创建certutil脚本。

下面的脚本是一个PureBasic脚本,只要按下空格键就会创建一个零字节的文件。

OpenConsole() 
String$ = Inkey()
If string$=" " 
  CreateFile(0, "quit.tmp")
  EndIf

下面这个批处理文件会创建一个 quit.exe 文件,该文件是我根据上面的脚本编译的,它展示了如何在循环中使用quit.exe。

在按下空格键之前,它什么也不做,然后退出循环。

@echo off
call :create_quit.exe
:loop
quit
if exist quit.tmp del quit.tmp & goto :exit
goto :loop
:exit
echo reached the end
del quit.exe
pause
goto :EOF


:create_quit.exe
(
echo(-----BEGIN CERTIFICATE-----
echo(TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
echo(AAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5v
echo(dCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEEAI1z2VUAAAAA
echo(AAAAAOAADwELAQIyAAwAAAAIAAAAAAAAABAAAAAQAAAAMAAAAABAAAAQAAAAAgAA
echo(BAAAAAAAAAAEAAAAAAAAAABQAAAABAAAAAAAAAMAAAAAABAAABAAAAA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quit.exe" >nul
del "quit.exe.decode"
© www.soinside.com 2019 - 2024. All rights reserved.