问题描述
有没有办法 CLS
一行输出?我不相信 CLS
有任何开关,所以也许更好的问题是:
有没有办法
- 保留所有以前的输出以便重复使用?
或 - 捕获当前显示的输出(像通过标记和复制一样)?
我只是试图通过提供实时反馈/信息来使我的脚本更加用户友好,而不是多条线略有变化。我可以想到这样做的唯一方法是这样:
@echo off
goto Prep
:Prep
SET count = 5
SET genericMessage =此窗口将关闭
goto输出
:输出
IF NOT%count%== -1(
cls
IF%count%== 0(
echo%genericMessage%now。
)ELSE(
echo%genericMessage%in%count%seconds。
)
SET / A count =%count% - 1
ping localhost -n 2> nul
goto输出
)ELSE(
exit
)
/ p>
>
但是,这个问题是 CLS
擦除所有输出,当我只想刷新
不幸的是,没有在Windows命令行控制台中重新定位光标的本机命令或实用程序。
您将需要第三方实用程序。 >
Aacini在DOSTips上发布了一个免费的CursorPos.exe实用程序。 以十六进制数字形式给出。要使用源代码,您需要。
浏览这两个主题,你会发现很多实用程序可能对你有用。
Is there any way to CLS
a single line of output? I don't believe there are any switches for CLS
, so maybe a better question would be:
Is there any way to
- retain all previous output for re-use?
or - capture currently displayed output (like you can by marking and copying)?
I'm just trying to make my scripts a little more user-friendly by having real-time feedback / information, instead of multiple lines with slight changes. The only way I can think of doing this, though, is like this:
@echo off
goto Prep
:Prep
SET count=5
SET genericMessage=This window will close
goto Output
:Output
IF NOT %count% == -1 (
cls
IF %count% == 0 (
echo %genericMessage% now.
) ELSE (
echo %genericMessage% in %count% seconds.
)
SET /A count=%count% - 1
ping localhost -n 2 >nul
goto Output
) ELSE (
exit
)
So, you get this:
The problem with this, though, is that CLS
erases all output, when I only want to refresh one line by erasing and re-outputting it.
Anyone have any ideas?
Unfortunately, there is no native command or utility that repositions your cursor in a Windows command line console.
You will need a 3rd party utility.
Aacini posted a free CursorPos.exe utility on DOSTips. The CurorPos.exe "source" is given as Hex digits. To use the source you will need the HexToBin.bat "compiler".
Browse both threads and you will find a number of utilities you may find useful.
这篇关于CLS(清除)单行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!