Windows的Snipping工具可以捕捉屏幕,但有时我想在五秒钟后捕捉屏幕,例如拍摄网络摄像头显示的图像。(例如,运行脚本并对着镜头微笑。)
如何在批处理文件中休眠5秒?
Windows的Snipping工具可以捕捉屏幕,但有时我想在五秒钟后捕捉屏幕,例如拍摄网络摄像头显示的图像。(例如,运行脚本并对着镜头微笑。)
如何在批处理文件中休眠5秒?
当前回答
下面的黑客让你睡5秒钟
ping -n 6 127.0.0.1 > nul
由于ping在两次ping之间等待一秒钟,因此您必须指定一次以上的ping。
其他回答
如果你有选择或ping,这是可行的。
@echo off
echo.
if "%1"=="" goto askq
if "%1"=="/?" goto help
if /i "%1"=="/h" goto help
if %1 GTR 0 if %1 LEQ 9999 if /i "%2"=="/q" set ans1=%1& goto quiet
if %1 GTR 0 if %1 LEQ 9999 set ans1=%1& goto breakout
if %1 LEQ 0 echo %1 is not a valid number & goto help
if not "%1"=="" echo.&echo "%1" is a bad parameter & goto help
goto end
:help
echo SLEEP runs interactively (by itself) or with parameters (sleep # /q )
echo where # is in seconds, ranges from 1 - 9999
echo Use optional parameter /q to suppress standard output
echo or type /h or /? for this help file
echo.
goto end
:askq
set /p ans1=How many seconds to sleep? ^<1-9999^>
echo.
if "%ans1%"=="" goto askq
if %ans1% GTR 0 if %ans1% LEQ 9999 goto breakout
goto askq
:quiet
choice /n /t %ans1% /d n > nul
if errorlevel 1 ping 1.1.1.1 -n 1 -w %ans1%000 > nul
goto end
:breakout
choice /n /t %ans1% /d n > nul
if errorlevel 1 ping 1.1.1.1 -n 1 -w %ans1%000 > nul
echo Slept %ans1% second^(s^)
echo.
:end
只需将其命名为sleep.cmd或sleep.bat并运行它
您可以使用VBScript,例如文件myscript.vbs:
set wsobject = wscript.createobject("wscript.shell")
do while 1=1
wsobject.run "SnippingTool.exe",0,TRUE
wscript.sleep 3000
loop
批处理文件:
cscript myscript.vbs %1
我编写了一个powerbasic程序wait.exe,在批处理文件中向它传递一个毫秒参数
wait 3000
system('c:/windows/system32/SnippingTool.exe')
EXE的代码:
FUNCTION PBMAIN()
c$ = Command$
s! = Val(c$)*1000
Sleep s!
END FUNCTION
超时/t 1>nul
就像在1秒内暂停一样,你可以将时间延长到近100.000(99.999)秒。如果您连接到互联网,最好的解决方案是:
平1.1.1.1-n 1-w 1000>无
当你ping时,你的计数单位是毫秒,所以一秒钟就是1000毫秒。但是ping命令有点可疑,它在脱机机器上的工作方式不同。问题是,由于机器处于离线状态,它会感到困惑,它想ping一个网站/服务器/主机/ip,但它不能。所以我建议超时。祝你好运
我认为以下命令可以帮助您:
pause 5
pause命令的语法为:pause d\\其中d表示持续时间(秒)
我使用的是Windows 7(32位),但我不知道其他的。