loading

Batch: How to make a menu's questions dif. colors without changing the entire menu color?

Hey guys, I'm kinda new. Please tell me how you make a menu in batch that has, for example, a different color for each option. I've seen it done in MUDs such as BallteTech., picture down below. I have been trying to figure out how, but I don't know if it is even possible... Thank you!

P.S. I'm not advertising, it's not even mine, nor do I claim it as mine or have anything to dow ith the game BattleTech itself. I'm only using it as an example. All credits go to their owners, blah blah...

Picture of Batch: How to make a menu's questions dif. colors without changing the entire menu color?
sort by: active | newest | oldest
Most of this is inspired by g-one's code:

@echo off
for /f "delims=#" %%a in ('"prompt #$H# &for %%b in (1) do rem"') do set "bs=%%a"
setlocal enabledelayedexpansion
color 0a
title Colour Changer

:start
cls
set /p text=Type the text you want to change colours here:
set /p colour=Type the colour code here:

<nul >"%text%.@" set /p "=.%bs%%bs%%bs%%bs%"

findstr /p /a:%colour% . "*.@"
del %text%.@
pause >nul
goto start



Hope this helps XD
account3r26 years ago
what is that... i see it is in telnet, but what is it? please tell me. oh, and you said you got the answer. what is it if you do have it?
lemonie7 years ago
Do you know this site?
www.dostips.com/

L
TheBatchies (author)  lemonie7 years ago

Yes, now I do! Thanks!

I rarely touch batch script these days, but that site does have a lot of good content.

L
TheBatchies (author)  lemonie7 years ago
Yeah. The only thing I didn't understand was the part I was looking for: ANSI! Haha oh well. I'll get it eventually... Hopefully. Thanks again!
ANSI is a character set, like ASCII.
The color basics are here:
www.dostips.com/DosCommandIndex.htm#COLOR

L
TheBatchies (author)  lemonie7 years ago
All right, thank you very much.
TheBatchies (author)  TheBatchies7 years ago
OK, so I go to Command Prompt, and type in PROMPT $E. It shows a little arrow pointing left. All of the websites are telling me to then type in [1;36m for a red color, or something with SETCOLOR, but it says that either one does not exist as a command. What am I missing?
Sorry, that's the entire window.
Try this one - needs getcolorcode linked at the top. I don't use these things but I'm sure they work - CTRL-C/V it.
Function.echo

L
TheBatchies (author)  lemonie7 years ago
AHHHH AHHHAAA! Thank you so much, I finally got it! You rock, man!
TheBatchies (author)  lemonie7 years ago
Dang, I thought I knew a thing or two. Sorry I'm wasting your time, it just seems like there isn't enough description about how to use it and stuff... Thank you so much.
www.dostips.com/
There you will find the missing function getColorCode.
Write your batch:

@echo off &setlocal
call :echo RedYellow TEXT 1
call :echo BlueWhite TEXT 2
call :echo WhiteBlack TEXT 3
pause

del /q "%temp%\color*.com"
goto :eof
:: ~~~~

:echo col txt -- echoes text in a specific color
:: here the rest of the function!
:: ~~~~

:getColorCode col ret -- converts color text to color code
:: here the rest of the function!
TheBatchies (author)  g-one7 years ago
:\ Not working... Thanks everybody, but I guess I'll be done here. No more answers, my computer either isn't good enough or I'm not ready yet. Thank you all for your awesome help and support!!!
g-one lemonie7 years ago
I'm impressed. But creating and calling a *.com file for each color takes a lot of time and thats why it is verry slow.
BTW not sure if *.com files are executable on a 64bit OS.
NachoMahma7 years ago
TheBatchies (author)  NachoMahma7 years ago
Will do, thank you.
g-one7 years ago
No chance with native batch. You can use the COLOR command only for the whole batch window.
TheBatchies (author)  g-one7 years ago
That's what I figured, thanks.