Batch Color per line

前端 未结 9 1255
耶瑟儿~
耶瑟儿~ 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:26

    You can try this simple script. It does not use temporary files. Just be sure you have the "debug.exe" executable in any folder listed in "%path%" environment variable.

    @echo off
    rem Script written by BrendanSilva [bl8086]
    rem You need DEBUG.EXE executable in your system.
    setlocal enabledelayedexpansion
    set /a _er=0
    set /a _n=0
    set _ln=%~4
    goto init
    :howuse ------------------------------------------------------------------------
        echo.
        echo ECOL.BAT - v2.0
        echo Print colored text as batch script without temporary files.
        echo Written by bl8086
        echo.
        echo Syntax:
        echo ECOL.BAT [COLOR] [X] [Y] "Insert your text here"
        echo COLOR value must be a hexadecimal number like "color /?" information
        echo.
        echo Example:
        echo ECOL.BAT F0 20 30 "640K ought to be enough for anybody."
        echo.
        goto :eof
    :error ------------------------------------------------------------------------
        set /a "_er=_er | (%~1)"
        goto :eof
    :gcnvhx ------------------------------------------------------------------------
        set _cvhx=
        set /a _cvint=%~1
    :cnvhx
        set /a "_gch = _cvint & 0xF"
        set _cvhx=!nsys:~%_gch%,1!%_cvhx%
        set /a "_cvint = _cvint >> 4"
        if !_cvint! neq 0 goto cnvhx
        goto :eof
    :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. Check memory out.
            echo.
            goto howuse
        )
        set nsys=0123456789ABCDEF
        set /a cnb=0
        set /a cnl=0
        set _cvhx=0
        set _cvint=0
        set _cvmhx=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 * 0xA0) + (_px << 1)) & 0xFFFF"
        call :gcnvhx %in%
        set ntr=!_cvhx!
        set /a jmp=0xe
        set bl8086str=echo.h 0 0
        @for /l %%x in (0,1,%cnl%) do (
            set bl8086str=!bl8086str!^&echo.eb800:!ntr! !bln%%x!
            set /a "in=!jmp! + 0x!ntr!"
            call :gcnvhx !in!
            set ntr=!_cvhx!
            set /a jmp=0x10
        )
        (
        echo %bl8086str%
        echo.q
        ) |debug >nul 2>&1
    

    This script can write your text in any screen position. Also using any color.

提交回复
热议问题