First solution uses escape sequences just for cursor movement, other graphics is ASCII:
Code: Select all
@echo off
cls
echo P R O G R E S S B A R
call :createbinvalue 27 DEL
call :createbinvalue 218 DEL
call :createbinvalue 196 DEL
call :createbinvalue 191 DEL
call :createbinvalue 179 DEL
call :createbinvalue 192 DEL
call :createbinvalue 217 DEL
call :createbinvalue 219 DEL
echo.
echo.
echo.
echo.
echo.
echo.
set esc=%char27%
REM hide cursor
echo %esc%[?25l
set spaces=&rem
set filler=&rem
set lines=&rem
for /L %%f in (1,1,80) do call set spaces= %%spaces%%
for /L %%a in (1,1,78) do call set filler=%%char219%%%%filler%%
for /L %%f in (1,1,78) do call set lines=%%char196%%%%lines%%
set "line0=0 %% 50 %% 100 %%"
set line1=%char218%%lines%%char191%<nul
set line3=%char192%%lines%%char217%<nul
set /a cnt=0
set /a cnt_all=200
:0
set /a percent=100 * cnt / cnt_all
call :drawprogressbar %percent% "downloading %cnt%"
set /a cnt+=1
if not "%cnt%"=="201" goto :0
REM show cursor
echo %esc%[?25h
goto :EOF
:drawprogressbar
REM par1=percent
REM par2=text to echo
set line4=%~2%spaces%
set line4=%line4:~0,78%
title %cnt%
set /a proc=(78 * %1 + 22 ) / 100
call set str1=%%filler:~0,%proc%%%
set str1=%str1%%spaces%
set str1=%str1:~0,78%
set line2=%char179%%str1%%char179%<nul
echo %esc%[9F%esc%[1G
echo.
echo %line0%
echo %line1%
echo %line2%
echo %line3%
echo.
echo %line4%
goto :EOF
:createbinvalue
REM par1=decima value between 0 and 255
REM par2: if DEL set the variable only (delete chr file)
md _chrs_>nul 2>nul
if exist _chrs_\%1.chr goto :gonext
set "options=/d compress=off /d reserveperdatablocksize=26"
if %~1 neq 26 (type nul >_chrs_\t.tmp
makecab %options% /d reserveperfoldersize=%~1 _chrs_\t.tmp _chrs_\%~1.chr >nul
type _chrs_\%~1.chr | (
(for /l %%N in (1 1 38) do pause)>nul&findstr "^">_chrs_\t.tmp)
>nul copy /y _chrs_\t.tmp /a _chrs_\%~1.chr /b
del _chrs_\t.tmp
) else (copy /y nul + nul /a _chrs_\26.chr /a >nul)
:gonext
if "%2"=="DEL" (
for /F "delims=" %%y in (_chrs_\%1.chr) do set "char%1=%%y"
del _chrs_\%1.chr
rd _chrs_
)
goto :EOF
Code: Select all
@echo off
cls
echo P R O G R E S S B A R
call :createbinvalue 27 DEL
call :createbinvalue 219 DEL
echo.
echo.
echo.
echo.
echo.
echo.
set esc=%char27%
REM hide cursor
echo %esc%[?25l
set spaces=&rem
set filler=&rem
set lines=&rem
for /L %%f in (1,1,80) do call set spaces= %%spaces%%
for /L %%a in (1,1,78) do call set filler=%%char219%%%%filler%%
for /L %%f in (1,1,78) do call set lines=q%%lines%%
set "line0=0 %% 50 %% 100 %%"
set line1=l%lines%k<nul
set line3=m%lines%j<nul
set /a cnt=0
set /a cnt_all=200
:0
set /a percent=100 * cnt / cnt_all
call :drawprogressbar %percent% "downloading %cnt%"
set /a cnt+=1
if not "%cnt%"=="201" goto :0
REM show cursor
echo %esc%[?25h
goto :EOF
:drawprogressbar
REM par1=percent
REM par2=text to echo
set line4=%~2%spaces%
set line4=%line4:~0,78%
title %cnt%
set /a proc=(78 * %1 + 22 ) / 100
call set str1=%%filler:~0,%proc%%%
set str1=%str1%%spaces%
set str1=%str1:~0,78%
set line2=x%str1%x<nul
echo %esc%[9F%esc%[1G
echo.
echo %esc%(0%line0%
echo %line1%
echo %line2%
echo %line3%%esc%(B
echo.
echo %line4%
goto :EOF
:createbinvalue
REM par1=decima value between 0 and 255
REM par2: if DEL set the variable only (delete chr file)
md _chrs_>nul 2>nul
if exist _chrs_\%1.chr goto :gonext
set "options=/d compress=off /d reserveperdatablocksize=26"
if %~1 neq 26 (type nul >_chrs_\t.tmp
makecab %options% /d reserveperfoldersize=%~1 _chrs_\t.tmp _chrs_\%~1.chr >nul
type _chrs_\%~1.chr | (
(for /l %%N in (1 1 38) do pause)>nul&findstr "^">_chrs_\t.tmp)
>nul copy /y _chrs_\t.tmp /a _chrs_\%~1.chr /b
del _chrs_\t.tmp
) else (copy /y nul + nul /a _chrs_\26.chr /a >nul)
:gonext
if "%2"=="DEL" (
for /F "delims=" %%y in (_chrs_\%1.chr) do set "char%1=%%y"
del _chrs_\%1.chr
rd _chrs_
)
goto :EOF
![Image](https://brickshelf.com/gallery/miskox/tmp/progress_bar_2024.png)
Of course color could be added...
Saso