How to change text color of cmd with windows batch script every 1 second
I have created a simple way of doing such and made it simple as possible. At the "pause" at the end is where you would continue your code. Picture of executed Code
# [CODE] [DESCRIPTION]
#
# echo. & starts a new line
# echo. skips a line
# PainText 08 08 is color code for gray Type "color ?" for color codes
# " Red" The space befor text gives space between the word befor it
@echo off
cls && color 08
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (set "DEL=%%a")
<nul set /p=""
call :PainText 08 "Gray"
call :PainText 04 " Red"
call :PainText 02 " Green"
call :PainText 08 " Gray"
echo. &
call :PainText 02 "Line 2 Green No space"
echo. &
echo.
call :PainText 01 "H"
call :PainText 02 "E"
call :PainText 03 "L"
call :PainText 03 "L"
call :PainText 05 "O"
echo.
goto :end
:PainText
<nul set /p "=%DEL%" > "%~2"
findstr /v /a:%1 /R "+" "%~2" nul
del "%~2" > nul
goto :eof
:end
echo.
pause
This should fit the bill. Sounds like a super-annoying thing to have going on, but there you have it:
@echo off
set NUM=0 1 2 3 4 5 6 7 8 9 A B C D E F
for %%x in (%NUM%) do (
for %%y in (%NUM%) do (
color %%x%%y
timeout 1 >nul
)
)
Try this script. This can write any text on any position of screen and don't use temporary files or ".com, .exe" executables. Just make shure you have the "debug.exe" executable in windows\system or windows\system32 folders.
http://pastebin.com/bzYhfLGc
@echo off
setlocal enabledelayedexpansion
set /a _er=0
set /a _n=0
set _ln=%~4
goto init
:howuse ---------------------------------------------------------------
echo ------------------
echo ECOL.BAT - ver 1.0
echo ------------------
echo Print colored text in batch script
echo Written by BrendanLS - http://640kbworld.forum.st
echo.
echo Syntax:
echo ECOL.BAT [COLOR] [X] [Y] "Insert your text"
echo COLOR value must be a hexadecimal number
echo.
echo Example:
echo ECOL.BAT F0 20 30 "The 640KB World Forum"
echo.
echo Enjoy ;^)
goto quit
:error ----------------------------------------------------------------
set /a "_er=_er | (%~1)"
goto quit
:geth -----------------------------------------------------------------
set return=
set bts=%~1
:hshift ---------------------------------------------------------------
set /a "nn = bts & 0xff"
set return=!h%nn%!%return%
set /a "bts = bts >> 0x8"
if %bts% gtr 0 goto hshift
goto quit
:init -----------------------------------------------------------------
if "%~4"=="" call :error 0xff
(
set /a _cl=0x%1
call :error !errorlevel!
set _cl=%1
call :error "0x!_cl! ^>^> 8"
set /a _px=%2
call :error !errorlevel!
set /a _py=%3
call :error !errorlevel!
) 2>nul 1>&2
if !_er! neq 0 (
echo.
echo ERROR: value exception "!_er!" occurred.
echo.
goto howuse
)
set nsys=0123456789abcdef
set /a _val=-1
for /l %%a in (0,1,15) do (
for /l %%b in (0,1,15) do (
set /a "_val += 1"
set byte=!nsys:~%%a,1!!nsys:~%%b,1!
set h!_val!=!byte!
)
)
set /a cnb=0
set /a cnl=0
:parse ----------------------------------------------------------------
set _ch=!_ln:~%_n%,1!
if "%_ch%"=="" goto perform
set /a "cnb += 1"
if %cnb% gtr 7 (
set /a cnb=0
set /a "cnl += 1"
)
set bln%cnl%=!bln%cnl%! "!_ch!" %_cl%
set /a "_n += 1"
goto parse
:perform --------------------------------------------------------------
set /a "in = ((_py * 160) + (_px * 2)) & 0xffff"
call :geth %in%
set ntr=!return!
set /a jmp=0xe
@for /l %%x in (0,1,%cnl%) do (
set bl8086%%x=eb800:!ntr! !bln%%x!
set /a "in=!jmp! + 0x!ntr!"
call :geth !in!
set ntr=!return!
set /a jmp=0x10
)
(
echo.%bl80860%&echo.%bl80861%&echo.%bl80862%&echo.%bl80863%&echo.%bl80864%
echo.q
)|debug >nul 2>&1
:quit