43

color 命令与更改 windows 命令提示背景/文本的颜色有关

color 0A - 其中 0 是背景颜色,A 是文本颜色

我想在 Windows 批处理脚本中每 1 秒更改这些文本颜色,使用 1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 的数组颜色代码。

0 = Black       8 = Gray
1 = Blue        9 = Light Blue
2 = Green       A = Light Green
3 = Aqua        B = Light Aqua
4 = Red         C = Light Red
5 = Purple      D = Light Purple
6 = Yellow      E = Light Yellow
7 = White       F = Bright White

该命令应该像这样每秒执行一次

color 01
color 02
color 03
....
color 0E
color 0F

对于这些,我找到了一些小脚本,但我不知道如何让它每 1 秒改变一次颜色!

for /L %%i in (1,1,%n%) do echo !array[%%i]!

或这个

@echo off CLS
for /l %%a in (15,-1,1) do (
color 0A
cls
)
pause

或这个

SET COUNTDOWN=15
:COUNTDOWNLOOP
IF %COUNTDOWN%==0 GOTO END
color 0A && %R1%
CLS
SET /A COUNTDOWN -=1
GOTO COUNTDOWNLOOP
:END
4

10 回答 10

36

这应该符合要求。听起来像是一件非常烦人的事情,但是你有它:

@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
    )
)
于 2012-09-26T20:59:42.393 回答
4

试试这个脚本。这可以在屏幕的任何位置写入任何文本,并且不使用临时文件或“.com、.exe”可执行文件。只需确保您在 windows\system 或 windows\system32 文件夹中有“debug.exe”可执行文件。

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
于 2014-02-02T12:18:57.810 回答
1

我正在做一些非常相似的事情。我刚刚开始编码,所以这可能不是最有效的方法,但我就是这样做的:

@ECHO OFF
ECHO HELLO
ping localhost -n 1 >nul
cls
color 01
ECHO HELLO
ping localhost -n 1 >nul
cls
color 02
ECHO HELLO 

等等。

于 2014-05-14T13:09:02.970 回答
1

我已经创建了一种简单的方法,并使其尽可能简单。最后的“暂停”是您继续代码的地方。 执行代码的图片

# [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
于 2016-12-31T20:18:01.270 回答
0
echo off & cls
set NUM=0 1 2 3 4 5 6 7 8 9 A B C D E F
for %%y in (%NUM%) do ( 
    for %%x in (%NUM%) do (
        color %%y%%x & for /l %%A in (1,1,200) do (dir /s)
        timeout 1 >nul
    )
)
pause
于 2017-08-02T18:52:45.097 回答
-1
echo off & cls
title   never buy these they're so easy to make... hmu for source code             

    -%pinging:IP%-
color 0D

echo =================================================================
echo i flex on my unhittable ovh, you flex on an easy to hit trash ovh
echo =================================================================
set /p IP=Enter IP:
:top
title :: this skid's boutta get slammed FeelsGoodMan ::    -%pinging:IP%-
PING -n 1 %IP% | FIND "TTL="
IF ERRORLEVEL (echo stop flexing on ovh's i down them with ease, mine on the other hand is unhittable.):
set /a num=(%Random%%%9)+1
color %num%IP   ping -t 2 0 10 127.0.0.1 >nul
GoTo top

这是一个 ip ping,它具有自定义超时消息,用于如果网站或服务器关闭,也可以用于引导人们离线,我可以制作一个工具,根据您的输入打开文件和单个 pinger,并且内置的地理位置工具。

于 2019-01-15T15:10:54.453 回答
-1

为了获得丰富多彩的用户体验,我使用了这个脚本来执行整套命令。我希望它有所帮助。

@echo off
color 01
timeout /t 2
color 02
timeout /t 2
color 03
timeout /t 2
color 04
timeout /t 2
color 05
timeout /t 2
于 2020-06-07T19:46:04.543 回答
-2

试试这个命令:

@echo off
cls
:loop
echo RAINBOW
color 0
echo RAINBOW
color 1
echo RAINBOW
color 2
echo RAINBOW
color 3
echo RAINBOW
color 4
echo RAINBOW
color 5
echo RAINBOW
color 6
echo RAINBOW
color 8
echo RAINBOW
color 9
echo RAINBOW
color A
echo RAINBOW
color B
echo RAINBOW
color C
echo RAINBOW
color D
echo RAINBOW
color E
echo RAINBOW
goto loop

这应该会循环创建颜色变化的文本。
编辑:您可以将彩虹一词更改为您想要的任何内容。

于 2020-05-28T16:46:20.447 回答
-2
@echo off
set NUM=0 1 2 3 4 5 6 7 8 9 A B C D E F 31 32 33 34 35 36 37 41 42 43 44 45 46 90 91 92 93 94 95 96 97 100 101 102 103 104 105 106 107 
for %%x in (%NUM%) do ( 
    for %%y in (%NUM%) do (
        color %%x%%y
cls
echo Himel Sarkar
        timeout 1 >nul
    )
)

pause
于 2020-09-12T15:13:41.833 回答
-4

通过在 cmd 窗口属性中编辑颜色值,可以将特定计算机上的颜色代码分配给不同的 RGB 颜色。轻松单击调色板上的颜色并更改其 rgb 值。

于 2013-12-05T11:43:04.760 回答