Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Console Text Color

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Thu Jan 01, 2009 9:38 am    Post subject: Console Text Color Reply with quote

How would I use a custom color, like brown, for the text in a console? I've used CreateConsoleScreenBuffer, and that didn't help.
_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
FerrisBuellerYourMyHero
Master Cheater
Reputation: 0

Joined: 14 Feb 2007
Posts: 401
Location: Inside your <kernel>

PostPosted: Thu Jan 01, 2009 10:59 am    Post subject: Reply with quote

Well there are two ways that I know of and use.

The first is the systems "color" command. open a cmd.exe and type "color /?" for help on using it. You should be able to figure it out.

And in c++ for example, you could do system("color 0c"); which would give a black background with red text. The thing is about this one is that it changes the color of all the text in your console window so you may not want that.


Instead you might want to have certain output be in a certain color and other output in a different color. For that I use GetStdHandle(), and SetConsoleTextAttribute().

C++ example:

Code:


HANDLE OutputHandle;

OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleTextAttribute(OutputHandle, FOREGROUND_BLUE | FOREGROUND_INTENSITY);

printf("this is blue text");

SetConsoleTextAttribute(OutputHandle, FOREGROUND_RED | FOREGROUND_INTENSITY);

printf("this is red text");



doing it like that, the blue text will retain its color when you set the new text attribute.

There is only a few defined colors though

from msdn;

FOREGROUND_BLUE
FOREGROUND_GREEN
FOREGROUND_RED


But I think you can use more colors. You might want to try these, although I haven't tested them

Code:

#define BLACK 0
#define BLUE 1
#define GREEN 2
#define CYAN 3
#define RED 4
#define MAGENTA 5
#define BROWN 6
#define LIGHTGREY 7
#define DARKGREY 8
#define LIGHTBLUE 9
#define LIGHTGREEN 10
#define LIGHTCYAN 11
#define LIGHTRED 12
#define LIGHTMAGENTA 13
#define YELLOW 14
#define WHITE 15
#define BLINK 128


_________________
You know, life moves pretty fast. If you don't stop and look around once in a while, You could miss it!

Back to top
View user's profile Send private message MSN Messenger
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Thu Jan 01, 2009 11:57 am    Post subject: Reply with quote

6 is Dark Yellow. I'm talking about using custom color like with brushes.

I wanted to be able to use this as a color RGB(128, 68, 0)

_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Thu Jan 01, 2009 4:25 pm    Post subject: Reply with quote

You can only use 0, 128 or 255 RGB in a console.
0 - Don't pass the color as a parameter.
128 - Pass the color as a parameter.
255 - Pass the color as a parameter with FOREGROUND_INTENSITY.


Last edited by Symbol on Fri Jan 02, 2009 2:14 pm; edited 1 time in total
Back to top
View user's profile Send private message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Thu Jan 01, 2009 5:44 pm    Post subject: Reply with quote

So what you are saying is that I'm stuck with those 15 text colors? But when you open up a console window and go to properties -> Colors you can change the colors to any value.
_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri Jan 02, 2009 1:59 pm    Post subject: Reply with quote

cmd.exe is a bit diffrent than the console window C/C++ programs use, when you run a program through the compiler without debugging it starts cmd.exe and using cmd.exe to run your process.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites