1

Is there a way to change the black background of the cmd window that open when

running the function to another color?

Roy Avidan
  • 769
  • 8
  • 25

3 Answers3

2

On Windows this can be done with an easy system call.

system("color <hexval><hexval>");

For example:

system("color 0a");

will change the background colour to black, and the foreground colour to green.

By opening a command prompt in Windows, you can type "color", and it will output all the possible variations. Then just try them out and implement it in your code.

SimonC
  • 1,547
  • 1
  • 19
  • 43
1

Right click on top bar of cmd then click properties then go to Colors tab and select your color then ok.

#Edited

use system(color 17);

it will give you white font on blue background. here 1 for blue and 7 for white. remember first code for background color and second code for font color.

here is some color codes.

A = Light Green     
B = Light Aqua 
C = Light Red 
D = Light Purple 
E = Light Yellow
F = Bright White
0 = Black 
1 = Blue   
2 = Green 
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White 
8 = Gray    
9 = Light Blue 
  
 
Sabir Hossain
  • 1,183
  • 1
  • 25
  • 46
  • I mean to a code that do that. – Roy Avidan Feb 20 '17 at 08:34
  • like the function that change the text-color. – Roy Avidan Feb 20 '17 at 08:35
  • for the background-color – Roy Avidan Feb 20 '17 at 08:35
  • `system(color 17);` it will give you white font on blue background. here 1 for blue and 7 for white. remember first code for background color and second code for font color. here is color codes `0 = Black 8 = Gray 1 = Blue 9 = Light Blue 2 = Green A = Light Green 3 = Aqua B = Light Aqua 4 = Red C = Light Red 5 = Purple D = Light Purple 6 = Yellow E = Light Yellow 7 = White F = Bright White` – Sabir Hossain Feb 20 '17 at 13:10
0

you can use

color

command in cmd.

color

command takes one argument in which first character corresponds to background and second character corresponds to foreground. Provide the character in HEX format.

0=BLACK  1=BLUE
2=GREEN  3=AQUA
4=RED  5=PURPLE
6=YELLOW  7=WHITE
8=GRAY  9=LIGHT BLUE
A=LIGHT GREEN  B=LIGHT AQUA
C=LIGHT RED  D=LIGHT PURPLE
E=LIGHT YELLOW  F=BRIGHT WHIT

for more help You can type

`color /?` 

in command Prompt Thanks

Vishwajeet Vishu
  • 492
  • 3
  • 16