我有这个脚本,我不能设法得到多个字符串颜色。 这是脚本:如何在此批处理文件中使用多个字符串颜色?
:Sentence 1
@echo off
setlocal enableextensions enabledelayedexpansion
set lines=1
set "line1=This Line in Blue, please" && set LineCount=26
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
for /L %%a in (1,1,%lines%) do set num=0&set "line=!line%%a!"&call :type1
pause>nul
goto :EOF
:type1
set /a LineCount-=1
if %LineCount% == 0 ping localhost /n 2 >nul && goto Sentence2
set "letter=!line:~%num%,1!"
set "delay=%random%%random%%random%%random%%random%%random%%random%"
set "delay=%delay:~-6%"
if not "%letter%"=="" set /p "=a%bs%%letter%" <nul
for /L %%b in (1,40,%delay%) do rem
if "%letter%"=="" echo.&goto :EOF
set /a num+=1
goto type1
:Sentence2
@echo off
setlocal enableextensions enabledelayedexpansion
echo.
set lines=1
set "line1=This Line in Red, please" && set LineCount=25
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
for /L %%a in (1,1,%lines%) do set num=0&set "line=!line%%a!"&call :type2
pause>nul
goto :EOF
:type2
set /a LineCount-=1
if %LineCount% == 0 ping localhost /n 2 >nul && goto end
set "letter=!line:~%num%,1!"
set "delay=%random%%random%%random%%random%%random%%random%%random%"
set "delay=%delay:~-6%"
if not "%letter%"=="" set /p "=a%bs%%letter%" <nul
for /L %%b in (1,40,%delay%) do rem
if "%letter%"=="" echo.&goto :EOF
set /a num+=1
goto type2
end
echo.
pause
exit
现在我想获得不同的颜色这两个字符串: - 此行的蓝色,红色请 - 这行,请
我试过FINDSTR /L
和COLOR /n
,但我无法设法正确.....我知道该批并不真正支持多个颜色在一个命令窗口中,但它可能与外部文件。
任何人都可以帮我吗?
〜Czgb
由于您没有张贴代码显示尝试的色彩输出,你的问题是题外话。该网站的想法是,你研究和学习自己张贴你的代码,并突出你的特定区域的困难。您可以先从命令提示符下查看'COLOR /?'和'FINDSTR /?',因为您显然还没有这样做。您可以使用网站搜索和/或您选择的搜索引擎来完成您的研究,然后您可以[编辑您的问题](https://stackoverflow.com/posts/46755447/edit)以相关代码进行更新并信息。 – Compo
@Compo我虽然有,但我无法做到这一点..我已经寻找解决方案,但没有我已经尝试的作品。这就是我提出这个问题的原因。 –
Stack Overflow搜索[\ [batch-file \] colors](https://stackoverflow.com/search?q=%5Bbatch-file%5D+colors)列出了222个结果。我不相信这些解决方案都不适合你。也许你只需要更仔细地研究你的代码和发布的代码,并自己尝试更多。或者是发布的脚本不是“* your *”脚本代码,并且您不知道它是如何工作的以及要修改哪些内容以显示不同颜色的输出行? – Mofi