Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ECHO OFF
- MODE CON: cols=110 lines=40
- REM - Required
- SETLOCAL EnableDelayedExpansion
- REM - Used in Function to Remove the Prompt.
- for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
- set "DEL=%%a"
- )
- REM - Use output of choice to assign Variables for Color Codes and Display info with TESTCC function
- :ColorSelect
- cls
- CHOICE /N /C:abcdef0123456789 /M "Select Background Color: A B C D E F 0 1 2 3 4 5 6 7 8 9"
- FOR %%a in ("!ERRORLEVEL!") do (
- CALL :TESTCC %%a bgcode bgcolor
- )
- CHOICE /N /C:abcdef0123456789 /M "Select Foreground Color: A B C D E F 0 1 2 3 4 5 6 7 8 9"
- FOR %%a in ("!ERRORLEVEL!") do (
- CALL :TESTCC %%a fgcode fgcolor
- )
- IF "!fgcode!"=="!bgcode!" (
- ECHO Colors Cannot Match.
- Timeout 2 > nul
- GOTO ColorSelect
- )
- cls
- REM - Display color code information, in plain colors and in selected colors.
- ECHO Color !bgcode!!fgcode! Foreground Code [!fgcode!] Color [!fgcolor!] Background Code [!bgcode!] Color [!bgcolor!]
- CALL :colorize "!bgcode!!fgcode!" "Color !bgcode!!fgcode! Foreground Code [!fgcode!] Color [!fgcolor!] Background Code [!bgcode!] Color [!bgcolor!]"
- ECHO.
- pause
- GOTO ColorSelect
- :TESTCC
- IF %~1==1 Set "%~2=a" && Set "%~3=Light Green"
- IF %~1==2 Set "%~2=b" && Set "%~3=Light Aqua"
- IF %~1==3 Set "%~2=c" && Set "%~3=Light Red"
- IF %~1==4 Set "%~2=d" && Set "%~3=Light Purple"
- IF %~1==5 Set "%~2=e" && Set "%~3=Light Yellow"
- IF %~1==6 Set "%~2=f" && Set "%~3=Light White"
- IF %~1==7 Set "%~2=0" && Set "%~3=Black"
- IF %~1==8 Set "%~2=1" && Set "%~3=Blue"
- IF %~1==9 Set "%~2=2" && Set "%~3=Green"
- IF %~1==10 Set "%~2=3" && Set "%~3=Aqua"
- IF %~1==11 Set "%~2=4" && Set "%~3=Red"
- IF %~1==12 Set "%~2=5" && Set "%~3=Purple"
- IF %~1==13 Set "%~2=6" && Set "%~3=Yellow"
- IF %~1==14 Set "%~2=7" && Set "%~3=White"
- IF %~1==15 Set "%~2=8" && Set "%~3=Grey"
- IF %~1==16 Set "%~2=9" && Set "%~3=light Blue"
- exit /b
- REM - Colorize function. To use: CALL colorcode "String in quotes"
- REM - Function works by creating a temporary file named using the string and Printing it Colored with FINDSTR
- :Colorize
- IF NOT EXIST "%TEMP%\colorize" md "%TEMP%\colorize"
- PUSHD %TEMP%\colorize
- <nul set /p ".=%DEL%" > "%~2"
- findstr /v /a:%1 /R "^$" "%~2" nul
- del "%~2" > nul 2>&1
- POPD
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment