bat退格符

Posted jack_孟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了bat退格符相关的知识,希望对你有一定的参考价值。

#bat等待# #bat退格符#折腾半天。方法不止这些,仅提供我运行成功的
#bat 在同一行列输出# #bat 在同一位置输出#=很好的使用退格符
 
 
 
脚本1:光标退格(不删除字符)
注意:下面脚本中 set /p=<nul (如果用记事本打开回事一个黑点,不要替换成其他字符。貌似:ALT 小键盘输入127)
 
@echo off&for /l %%a in (1 1 18) do echo\\
set /p=      <nul
for /l %%i in (1 1 70) do set /p=^|<nul
for /l %%i in (1 1 70) do set /p=<nul
for /l %%i in (1,1,70) do (
set/p=^><nul
for /l %%a in (1 1 1000) do ver>nul
)
echo\\&echo\\&pause
 
 
脚本2:设置退格符。看半天没看明白,不过能用。
 
执行代码后: %bs%等于了退格键。注意定义好变量名,避免重复。
@echo off
call:getbs bs
echo abc%bs%#
pause
:getbs 
for /F %%a in (\'"prompt $h&for %%b in (1) do rem"\')do Set "%~1=%%a"
 
 
脚本3:等待时间,使用VBS的方式。(BAT中最烂的地方就是没有提供sleep)
 
将下面文件保存成sleep.bat
然后通过 call sleep.bat 1000 的方式来暂停1s
 
@echo off
set wait_sencents=%1
 
IF "%wait_sencents%" EQU "". (
set wait_sencents=0
) ELSE (
set /a wait_sencents=%wait_sencents%
echo wscript.sleep %wait_sencents%>sleep.vbs
call wscript sleep.vbs
)
 
 
脚本4:批处理等待ping 不存在的IP地址的方式

You can ping a random address and specify the desired timeout:

ping 123.45 . 67.89 - n 1 - w 10000 > nul 

And since the address does not exists, it\'ll wait 10,000 ms (10 seconds) and returns.(注意IP地址要不能存在的,上面语句会wait   10,000 ms

The -w 10000 part specifies the desired timeout in milliseconds.
The -n 1 part tells ping that it should only tries once (normally it\'d try 4 times).
The > nul part is appended so the ping command doesn\'t output anything to screen.
 
 
rem ===============================================
其他:
 

以上是关于bat退格符的主要内容,如果未能解决你的问题,请参考以下文章

如何使用jQuery捕获退格键? [复制]

用于检查带有退格符的字符串是不是相等的节省空间的算法?

如何将退格键更改为 '\b'?

终端如何以编程方式在 shell 提示符下阻止退格,这样你就不能在它上面退格,例如$ 用于 bash 或 C:\blah\>

UItextfield shouldChangeCharactersInRange 方法退格不起作用

Android:WebView/BaseInputConnection 中的退格键