如何更改同一行中单个单词的文本颜色 CMD BAT BATCH

问题描述 投票:0回答:1

基本上想更改 cmd 中文本中间的单个单词,这是我想要做的事情的简短代码示例

@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"
)

color 0a
title App
cls

:welcome_page
cls
echo Welcome to App 
call :colorEcho 0C "Menu in red" :colorEcho 0B "and this text in a different color" :colorEcho 0C "back to red"
echo.
pause
exit

:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i
batch-file cmd colors console
1个回答
0
投票

很确定我已经尝试过了,但现在它可以工作了

call :colorEcho 0C "Menu"&call :colorEcho 0B "and this text in a different color"&call :colorEcho 0C "back to red"
echo.
call :colorEcho 0a "test"
echo.
pause
exit
© www.soinside.com 2019 - 2024. All rights reserved.