Colors 更改cmd窗口特定部分的颜色

Colors 更改cmd窗口特定部分的颜色,colors,cmd,Colors,Cmd,我想制作一个cmd,显示某个过程: 这是窗口的外观: ----------- | TESTING | <-- This text is in green, but background of this part is in black ----------- Process ... 1% <-- This text is in white 因此,问题是: 1. timeout/t 0.1/nobreak将不起作用,因为timeout/t必须是整数; 2.我想要的颜色不能改变 我

我想制作一个cmd,显示某个过程:
这是窗口的外观:

-----------
| TESTING |  <-- This text is in green, but background of this part is in black
-----------

Process ... 1% <-- This text is in white
因此,问题是: 1.
timeout/t 0.1/nobreak
将不起作用,因为
timeout/t
必须是整数; 2.我想要的颜色不能改变

我可以用其他编程语言来做这件事吗?
任何帮助都将不胜感激。谢谢

请尝试此操作以获得延迟。调整1000以调整延迟以适合您,但在速度较快或较慢的机器上,延迟会有所变化

for /L %%a in (1,1,1000) do rem
除了
color
关键字以外,cmd在颜色上有很大的限制,但是这个批处理文件演示了颜色的一些用法

第三方工具也可以让你给屏幕上色

@Echo Off
Call :Color A "######" \n E "" C " 21 " E "!" \n B "######" \n
Pause >Nul
Exit /B

:Color
:: v21
:: Arguments: hexColor text [\n] ...
:: \n -> newline ... -> repeat
:: Supported in windows XP, 7, 8.
:: In XP extended ascii characters are printed as dots.
:: For print quotes, use empty text.
SetLocal EnableExtensions EnableDelayedExpansion
Subst `: "!Temp!" >Nul &`: &Cd \
SetLocal DisableDelayedExpansion
If Not Exist `.7 (
Echo(|(Pause >Nul &Findstr "^" >`)
Set /P "=." >>` <Nul
For /F "delims=;" %%# In (
'"Prompt $H;&For %%_ In (_) Do Rem"') Do (
Set /P "=%%#%%#%%#" <Nul >`.3
Set /P "=%%#%%#%%#%%#%%#" <Nul >`.5
Set /P "=%%#%%#%%#%%#%%#%%#%%#" <Nul >`.7))
:__Color
Set "Text=%~2"
If Not Defined Text (Set Text=^")
SetLocal EnableDelayedExpansion
Set /P "LF=" <` &Set "LF=!LF:~0,1!"
For %%# in ("!LF!") Do For %%_ In (
\ / :) Do Set "Text=!Text:%%_=%%~#%%_%%~#!"
For /F delims^=^ eol^= %%# in ("!Text!") Do (
If #==#! EndLocal
If \==%%# (Findstr /A:%~1 . \` Nul
Type `.3) Else If /==%%# (Findstr /A:%~1 . /.\` Nul
Type `.5) Else (Echo %%#\..\`>`.dat
Findstr /F:`.dat /A:%~1 .
Type `.7))
If "\n"=="%~3" (Shift
Echo()
Shift
Shift
If ""=="%~1" Goto :Eof
Goto :__Color
@Echo关闭
呼叫:颜色A“\n E”“C”21“E”!“\n B”\n
暂停>Nul
退出/B
:颜色
::v21
::参数:hexColor文本[\n]。。。
::\n->newline…->重复
::在windows XP、7、8中受支持。
::在XP中,扩展ascii字符打印为点。
::对于打印引号,请使用空文本。
SetLocal EnableExtensions EnableDelayedExpansion
Subst`:“!Temp!”>num&`:&Cd\
SetLocal DisableDelayedExpansion
如果不存在`(
回音(|)(暂停>数字和查找字符串“^”>`)

设置/P“=。”>`

关于着色部分-您可以尝试使用。在您的情况下,它将非常简单:

echo \033[92m
echo -----------
echo | TESTING |
echo -----------
echo \033[0m

是的,那太好了,虽然行太长了^。^但事情是好的。对于这行:
For/l%%a in(1,11000)rem是否只是重复rem,因为没有输出,对吗?然而,我想知道运行
rem
echo 1>>a.abc
需要多长时间。是的,rem没有输出,这只是一个延迟。你可以使用
编写的名为
timethis
的工具kevin@microsoft.com
测量co的使用时间我拿着。
echo \033[92m
echo -----------
echo | TESTING |
echo -----------
echo \033[0m