CLS (clear) a single line?

后端 未结 4 997
南旧
南旧 2020-12-03 18:24

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:

相关标签:
4条回答
  • 2020-12-03 18:58

    An alternative quick&dirty method of moving the cursor via TIMEOUT:

    @echo off
    <nul set/p"=5 seconds till i close..."
    timeout /t 5 /nobreak >con
    echo(i'm closing now...[REPLACE this with lots of spaces]
    exit /b
    

    0 讨论(0)
  • 2020-12-03 18:59

    If you only need to move the cursor in one line (like your sample),
    it's possible with a carriage return character.

    @echo off
    setlocal EnableDelayedExpansion
    for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"
    for /L %%n in (5 -1 1) do (
      <nul set /P "=This window will close in %%n seconds!CR!"
      ping -n 2 localhost > nul
    )
    
    0 讨论(0)
  • 2020-12-03 18:59

    Try ANSI sequences: http://www.robvanderwoude.com/ansi.php

    Burrowing down the links, http://batch.xoo.it/t2238-BG-exe-Utility-for-Batch-Games.htm looks the most promising.

    This page sounds like it has useful discussion on controlling/setting console sizes (and other display and buffer size settings). http://www.pcreview.co.uk/forums/change-buffer-size-console-window-can-runas-inherit-console-props-t1468842.html

    0 讨论(0)
  • 2020-12-03 19:04

    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.

    0 讨论(0)
提交回复
热议问题