2868Views19Replies

Author Options:

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

Picture of

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

19 Replies

user
Prof. Pickle (author)2012-12-15

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

Select as Best AnswerUndo Best Answer

user
account3r2 (author)2010-09-24

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?

Select as Best AnswerUndo Best Answer

user
TheBatchies (author)lemonie2010-01-22
user
lemonie (author)TheBatchies2010-01-22

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

L

Select as Best AnswerUndo Best Answer

user
TheBatchies (author)lemonie2010-01-22

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!

Select as Best AnswerUndo Best Answer

user
TheBatchies (author)lemonie2010-01-23

All right, thank you very much.

Select as Best AnswerUndo Best Answer

user
TheBatchies (author)TheBatchies2010-01-23

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?

Select as Best AnswerUndo Best Answer

user
lemonie (author)TheBatchies2010-01-23

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

Select as Best AnswerUndo Best Answer

user
TheBatchies (author)lemonie2010-02-22

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

Select as Best AnswerUndo Best Answer

user
TheBatchies (author)lemonie2010-01-23

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.

Select as Best AnswerUndo Best Answer

user
g-one (author)TheBatchies2010-01-23

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!

Select as Best AnswerUndo Best Answer

user
TheBatchies (author)g-one2010-01-23

:\ 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!!!

Select as Best AnswerUndo Best Answer

user
g-one (author)lemonie2010-01-23

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.

Select as Best AnswerUndo Best Answer

user
g-one (author)2010-01-21

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

Select as Best AnswerUndo Best Answer

user
TheBatchies (author)g-one2010-01-22

That's what I figured, thanks.

Select as Best AnswerUndo Best Answer