问题描述
最近我对前几天提出的问题不满意,很快就收到了答复!希望对于那些有识之士来说,这是一个快速的选择.我已经搜索并玩了几个小时,只是没有得到它.
I was recently overwhelmed with quick responses for a question I had the other day! hopefully this will be a quick one for those in the know, I've searched and played for hours and just not getting it.
我发现可以修改批处理CMD中每个字符的颜色的代码,尽管不能使它适用于ASCII字符.
I have found code to modify color per character in batch CMD although cant make it work for ASCII characters.
这显示有错误的输出窗口:
This shows hows output window with errors:
这是我尝试修改以适合的代码,它准确地解释了正在发生的事情和正在尝试的事情:
Here's the code I've tried to modify to suit, it explains exactly whats happening and what im attempting:
@echo off
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
call :colorEcho 0a "This works!!"
echo.
call :colorEcho 0C "But ASCII characters don't"
echo.
echo expect this in set color
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º º
echo º º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
echo but get this instead?
echo.
call :colorEcho 0a "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
echo.
call :colorEcho 0a "º º"
echo.
call :colorEcho 0a "º º"
echo.
call :colorEcho 0a "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
pause
exit
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
推荐答案
一旦我停下来想一想,我的解决方案似乎比我想象的要简单.
Seems my solution was more simple than i ever expected, once i stopped and thought about it.
所以因为我希望所有扩展的ascii字符都是相同的颜色,所以很简单.
so because i want all extended ascii characters to be the same color its simple.
使用简单的颜色功能更改整个页面以匹配我想要的菜单边框的颜色(扩展的ascii字符)
change the whole page to match what color i want menu border (extended ascii characters) using simple color function
,然后使用我的原始脚本中的:colorEcho分别为所有文本着色.
and then color all the text separately using the call :colorEcho from my original script.
谢谢
这篇关于用批处理CMD彩色ASCII字符的单行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!