CLS(清)单行? [英] CLS (clear) a single line?

查看:119
本文介绍了CLS(清)单行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法 CLS 输出单行?我不相信有用于 CLS 任何开关,所以也许一个更好的问题是:

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:

有什么办法


  1. 保留再利用所有previous输出?


  2. 捕捉当前显示输出(如你可以通过标记和复制)?

我只是试图让我的剧本多了几分人性化的通过具有实时反馈/信息,而不是多行略有改动。我能想到这样做的唯一办法,虽然是这样的:

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:

这个问题,不过,是 CLS 删除全部输出,当我只希望通过擦除刷新一行,并重新输出它。

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.

任何人有什么想法?

推荐答案

不幸的是,重新定位光标在Windows命令行控制台没有原生的命令或程序。

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张贴在DOSTips免费CursorPos.exe工具。该 CurorPos.exe源是作为十六进制数字。要使用源您将需要 HexToBin.bat编译

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(清)单行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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