3034Views19Replies

Author Options:

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

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...

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
Prof. Pickle
Prof. Pickle

8 years ago

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

0
account3r2
account3r2

10 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?

0
TheBatchies
TheBatchies

Answer 11 years ago

Yes, now I do! Thanks!

0
lemonie
lemonie

Answer 11 years ago

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

L

0
TheBatchies
TheBatchies

Answer 11 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!

0
TheBatchies
TheBatchies

Answer 11 years ago

All right, thank you very much.

0
TheBatchies
TheBatchies

Answer 11 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?

0
lemonie
lemonie

Answer 11 years ago

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

0
TheBatchies
TheBatchies

Answer 11 years ago

AHHHH AHHHAAA! Thank you so much, I finally got it! You rock, man!

0
TheBatchies
TheBatchies

Answer 11 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.

0
g-one
g-one

Answer 11 years ago

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!

0
TheBatchies
TheBatchies

Answer 11 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!!!

0
g-one
g-one

Answer 11 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.

0
TheBatchies
TheBatchies

Answer 11 years ago

Will do, thank you.

0
g-one
g-one

11 years ago

No chance with native batch. You can use the COLOR command only for the whole batch window.

0
TheBatchies
TheBatchies

Answer 11 years ago

That's what I figured, thanks.