Batch Color per line

前端 未结 9 1214
耶瑟儿~
耶瑟儿~ 2020-11-28 11:47

In batch, can you have different colors per line. For example if you had a batch file say \"Hello\" \"How are you?\"

Could you have \"Hello\" in blue and \"How are y

相关标签:
9条回答
  • 2020-11-28 12:37

    Just need of COLORMSG :

    @echo off
    (
    echo e100
    echo 0F B6 0E 80 00 E3 4F BF 81 00 B0 20 FC F3 AE 74
    echo e110
    echo 45 E3 43 8A 45 FF E8 43 00 80 3D 20 74 0E C0 E0
    echo e120
    echo 04 8A E0 8A 05 E8 34 00 0A C4 47 49 E3 28 32 E4
    echo e130
    echo 50 B0 22 F2 AE 75 1F E3 1D 8B F7 8B D1 F2 AE 75
    echo e140
    echo 01 41 2B D1 74 10 8B CA 5B B0 20 B4 09 CD 10 AC
    echo e150
    echo B4 0E CD 10 E2 F9 32 C0 B4 4C CD 21 3C 61 72 02
    echo e160
    echo 2C 20 3C 41 72 02 2C 07 2C 30 C3
    echo rcx
    echo 6b
    echo w
    echo q
    ) | debug colormsg.com > nul
    ren colormsg.com colormsg.exe
    

    Use the colors cmd default :

    color /?
    

    Use echo. to break line

    Use spacebar to move msg horizontally

    Example:

    @echo off
    
    REM one color in line
    echo.
    colormsg a "green color"
    
    REM break line
    echo.
    
    REM two colors in line
    colormsg b "color blue"
    colormsg c "color red"
    
    REM break line
    echo.
    
    REM two colors with spacing horizontally (no use tab)
    colormsg d "purple color"
    colormsg e "             yellow color"
    echo.
    echo.
    pause
    

    that's all !!

    0 讨论(0)
  • 2020-11-28 12:42

    You can try this just with a little bit of command:

    @echo off
    chcp 437>nul&&graftabl 936>nul
    ren %WinDir%\System32\config.nt config.nt.bak 2>nul
    <"%~f0" more +6 >%WinDir%\System32\config.nt
    command /cecho [1;31mHel[32mlo [33mHow[35mare[36myou[m
    pause>nul&exit
    DOSONLY
    dos=high, umb
    device=%SystemRoot%\system32\himem.sys
    DEVICE==%SystemRoot%\System32\ANSI.SYS /x
    files=40
    
    0 讨论(0)
  • 2020-11-28 12:42

    Save it as colormsg.bat

    @echo off
    if "%~3" == "" goto usage
    powershell -command write-host -foreground "%~1" -background "%~2" -nonewline "%~3"
    exit /b
    :usage
    echo.
    echo Usage: call colormsg foreground background "message"
    echo.
    echo Examples:
    echo call colormsg white blue "example1"
    echo call colormsg 4 2 "example2"
    

    Example:

    @echo off
    for /f %%a in ('"prompt $H & for %%a in (-) do rem"') do set "BS=%%a"
    call colormsg blue 0 "Hello"
    <nul set /p "=.%BS% "
    call colormsg green 0 "How are you?"
    echo.
    pause
    
    0 讨论(0)
提交回复
热议问题