批处理文件:打字机影响 [英] Batch File: Typewriter Effect

查看:104
本文介绍了批处理文件:打字机影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚得到了code这样做的效果,但我需要做的更快,像一个字母每个0.5 SEGS。

I just got a code to do this effect, but i need to do it faster, like a letter each 0.5 segs.

for %%i in (h e l l o o o o o o o o o o o o o o) do (
   set /p a=%%i<nul
   ping 0.0.0.0 -n 2.0>nul 2>&1
)

有人知道如何修改呢?

Someone know how to modified it?

推荐答案

在上述评论的解决方案是用于安装的网络接口的电脑是值得的解决方案(因为几乎都有)。

The ping solution in the comments above is a worthwhile solution for computers with installed network interfaces (as almost all have).

@echo off
setlocal

for %%i in (h e l l o o o o o o o o o o o o o o) do (
   set /p "=%%i"<nul
   ping 169.254.0.0 -n 1 -w 500 >nul
)
echo;
goto :EOF

然而,似乎与这种方法识别的最小的等待时间为500ms。如果你改变了500至一个较低的值,你仍然停顿半秒字母之间。如果你想更好的控制,或者如果你的电脑没有网络接口,你必须从另一个运行环境借钱 - JScript中,例如:

However, it appears that the minimum wait time recognized with this method is 500ms. If you change the 500 to a lower value, you still pause a half second between letters. If you want finer control, or if your computer has no network interface, you'll have to borrow from another runtime environment -- JScript, for example.

@if (@CodeSection == @Batch) @then

@echo off
setlocal

for %%i in (h e l l o o o o o o o o o o o o o o) do (
   set /p "=%%i"<nul
   cscript /nologo /e:JScript "%~f0"
)
echo;

goto :EOF
rem // end batch portion

@end
// begin JScript chimera
WSH.Sleep(Math.random() * 250 + 100);


这是IP的选择平注意:作为 -w 切换到按预期工作,你必须平导致的IP请求超时。您可以使用一个不存在的局域网IP,如10.x.x.x或192.168.x.x.但对于wides $ P $垫部署中,如果你不能肯定这些范围是未使用的,在169.254范围内的本地链接IP应该只是罚款用于这一目的。请不要使用历史bogon空间中的IP像1.1.1.1 1.2.3.4或。正因为这样的地址不回复并不意味着你的数据包不增加网络拥塞的地方。


Note on the choice of IP to ping: For the -w switch to work as intended, the IP you ping must result in "Request timed out". You can use a non-existent LAN IP such as a 10.x.x.x or 192.168.x.x. But for widespread deployment, if you can't be certain that those ranges are unused, a link local IP in the range of 169.254 should work just fine for this purpose. Please do not use an IP in historical bogon space like 1.1.1.1 or 1.2.3.4. Just because such addresses don't reply doesn't mean your packets aren't adding to network congestion somewhere.

最后,随着IPv4地址借鉴以往任何时候都更接近完全枯竭,人们需要更加自觉用虚假信息流污染上网。这可能是1.1.1.1 1.2.3.4和,因为他们往往​​都被随意滥用,脚本编写者将永远是有用的人。但是,这没有理由加入到这些地址的虐待。 见本页面进一步阅读,并请,保存bogons。

Eventually as IPv4 addresses draw ever nearer to complete exhaustion, people need to be more conscientious of polluting the Internet with bogus traffic. It could be that 1.1.1.1 and 1.2.3.4 will never be useful to anyone because they are so often abused by casual scripters. But that's no reason to add to the mistreatment of those addresses. See this page for further reading, and please, save the bogons.

刚看到多远我可以采取打字机效果,我写了一个脚本,输出相似的X屏保杰克的文字。一遍又一遍地输出同一直线上,并随机推出印刷错误。运行它,你会如醉如痴,生根脚本完成行没有任何错别字。

Just to see how far I could take the typewriter effect, I wrote a script that outputs text similar to the X screensaver "Jack". It outputs the same line over and over, and randomly introduces typographical errors. Run it and you'll be mesmerized, rooting for the script to complete a line without any typos.

@if (@CodeSection == @Batch) @then

@echo off
setlocal

cls
color 70

call :split chars "All work and no play makes Jack a dull boy."

:begin
for %%i in (%chars%) do call :type "%%~i"
echo;
goto begin

:split <var_to_set> <str>
setlocal enabledelayedexpansion
set "line="
set "str=%~2"
for /L %%I in (0,1,43) do set line=!line! "!str:~%%I,1!"
endlocal & set %~1=%line%
goto :EOF

:type <char>
cscript /nologo /e:JScript "%~f0" "%~1"
goto :EOF

@end
// end batch / begin JScript chimera
function pause() { WSH.Sleep(Math.random() * 250 + 100); }
function odds(num) { return !(Math.round(Math.random() * num) % num) }
function backspace() { WSH.StdOut.Write(String.fromCharCode(8)); }

pause();

if (odds(15)) {
    WSH.StdOut.Write(String.fromCharCode(Math.round(Math.random() * 95 + 32)));
    pause();
    if (!odds(20)) {
        backspace();
        pause();
    }
}

if (odds(300)) WSH.Echo('');
if (!odds(400)) WSH.StdOut.Write(WSH.Arguments(0));

这篇关于批处理文件:打字机影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆