這不是你一個答案,但它顯示了一個微調,你可能沒見過的技術:
第二示範遵循它,但它可能無法在Windows 8中正常工作。
@Echo OFF
SetLocal EnableExtensions EnableDelayedExpansion
For /f %%a in ('copy /Z "%~dpf0" nul') Do set "CR=%%a"
Set "busy=|/-\"
Set /A n=0
::BUSY SPINNER
For /L %%i in (0,1,10) Do (
Set /A "n=%%i%%4"
For /L %%n in (!n! 1 !n!) Do Set /P "=Calculating !busy:~%%n,1! !CR!"<NUL:
PING -n 2 127.0.0.1 >NUL:
)
::COUNTDOWN
For /L %%i in (10,-1,1) Do (
Set /P "=Backup will begin in %%i seconds. !CR!"<NUL:
PING -n 2 127.0.0.1 >NUL:
)
::PROGRESS
For %%i in (*) Do (
Set /P "=Copying %%i !CR!"<NUL:
PING -n 2 127.0.0.1 >NUL:
)
Set /P "=Done. !CR!"<NUL:
pause
這裏是一個旋轉的紡絲的第二個演示:
@echo off
:jeb
setlocal EnableDelayedExpansion
if "%~1"==":::" goto :spinnerThread
:menuLoop
<nul set /p menu=Select menu[1 or 2]=
call :GetKey
echo(
echo Pressed '!key!'
if !key!==1 call :menu1
if !key!==2 call :menu2
if !key!==2 call :menu2
goto :menuLoop
:menu1
:menu2
call :spinnerStart
rem do some work
ping localhost -n 3 > nl
call :spinnerStop
echo Finished
exit /b
:spinnerStart
del spinnerStop.tmp > nul 2>&1
start /b "" cmd /c "%~df0" :::
exit /b
:spinnerStop
echo dummy > spinnerStop.tmp
:__spinnerStop
if exist spinnerStop.tmp goto :__spinnerStop
exit /b
:spinnerThread
for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"
set "spinChars=\|/-"
:spinnerLoop
set /a "spinner=(spinner + 1) %% 4"
<nul set /p ".=Waiting...!spinChars:~%spinner%,1!!CR!"
ping localhost -n 2 > nul 2>&1
if not exist spinnerStop.tmp goto :spinnerLoop
del spinnerStop.tmp > nul 2>&1
echo(
exit /b
:GetKey
set "key="
for /F "usebackq delims=" %%L in (`xcopy /L /w "%~f0" "%~f0" 2^>NUL`) do (
if not defined key set "key=%%L"
)
set "key=%key:~-1%"
exit /b
如果微調是在最後的印刷線,有可能改變它不清除屏幕。用'CR'字符顯示foxiderive或者退格字符 – jeb
foxidrive/jeb提到的'CR'或'BS'技巧是否解決了您的問題?如果沒有,也許我的[CursorPos](http://www.dostips.com/forum/viewtopic.php?f=3&t=3428&p=17216&hilit=CursorPos.exe#p17216)輔助程序可以幫助你(尋找程序#6 )。這個程序可以讓你將光標移動到某個特定的位置,然後在該位置讀取字符! – Aacini