Windows API color output to standard output in Powershell / cmd.exe

Does anyone know where to find a link that describes how to display color on Windows CLI using the API and / or stdout?

+4
source share
4 answers

The Win32 console API has a SetConsoleTextAttribute function that can be used to set the foreground and background text colors. Sample code here .

+3
source

At least there is a color command:

color bg fg 

Where:

 0: Black 1: Blue 2: Green 3: Cyan 4: Red 5: Purple 6: Yellow 7: Gray 8: Silver 9: Light blue A: Lime B: Light cyan C: Light red D: Light purple E: Light yellow F: White 

Example:

 color 80 

Gets a silver background with black text.

+1
source

Not quite a link, but it will help you find what you are looking for on MSDN, check:

http://www.gamedev.net/community/forums/topic.asp?topic_id=457528 .

You probably want to find "WriteConsoleOutput".

+1
source

in powershell, write-host accepts the values โ€‹โ€‹of the backgroundcolor and -foregroundcolor parameters

0
source

All Articles