T3RRYT3RR0R

Batch Same Line MultiColor Printer For Older Windows

Jan 2nd, 2020
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.40 KB | None | 0 0
  1. @echo off & MODE CON: cols=110 lines=140
  2.  
  3. REM - Required
  4.     SETLOCAL EnableDelayedExpansion
  5.  
  6. REM - Used in Function to Remove the Prompt.
  7.     For /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
  8.         set "DEL=%%a"
  9.     )
  10.  
  11. REM - Creates Color chart - To demonstrate the function
  12.  
  13.     For %%F in (a,b,c,d,e,f,1,2,3,4,5,6,7,8,9,0) Do (
  14.         For %%B in (a,b,c,d,e,f,1,2,3,4,5,6,7,8,9,0) Do (
  15.         IF NOT %%B==%%F (Call :Colorize %%F%%B "Color %%F%%B                                                                                                     I")
  16.         )
  17.         ECHO( Next...
  18.         Pause >nul
  19.         CLS
  20.     )
  21.  
  22. REM - New Lines need to be Forced While Using the Colorizer
  23.     ECHO(
  24.  
  25. REM - Example of printing multiple colors on same line:
  26. REM - Note: spaces at the end of strings will be stripped.
  27.     CALL :Colorize 0a "Hello World " && CALL :Colorize 0c " What's Up" && CALL :Colorize 8f " Good People"
  28.  
  29.     ECHO.
  30.     CALL :Colorize 0f "Colored by T3RRY"
  31.     ECHO.
  32.  
  33. REM - End of Demonstration
  34.     pause
  35.     goto :eof
  36.  
  37. REM - Colorize function. To use: CALL : Colorize <colorcode> <"String in quotes">
  38. REM - Function works by creating a temporary file named using the string and Printing it Colored with FINDSTR
  39. :Colorize
  40.     IF NOT EXIST "%TEMP%\colorize" md "%TEMP%\colorize"
  41.     PUSHD %TEMP%\colorize
  42.     <nul set /p ".=%DEL%" > "%~2"
  43.     findstr /v /a:%1 /R "^$" "%~2" nul
  44.     del "%~2" > nul 2>&1
  45.     POPD
  46.     goto :eof
Advertisement
Add Comment
Please, Sign In to add comment