2900Views19Replies

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

Discussions

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

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?

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

L

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!

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

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

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!

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

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
user
g-one

8 years ago

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