1,105,375 Community Members

Setcolor

Member Avatar
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

Setcolor was entirely programmed by Mahen of Mauritius. Who have never wished of changing the Font colors of the Command Prompt on the fly. Well this is where Setcolor comes in handy. The main function of this program is to change the default Font color of your Command Prompt. The colors start from 0 up to 9999. The following gives an example of the program's usage:


C:WINDOWS>setcolor 12

C:WINDOWS>setcolor -help

Usage: Setcolor -Help Displays this Message
-Default Returns the Font back to normal
"number" Changes the color of the Font according to number


NOTICE: You must not claim this program as yours!!!!

//******************************************************
//   Title:  Setcolor

//   File:   Setcolor.exe

//   Description:  A program to change the font color of command prompt.

//   Author:  Mahen

//   Developped:   Pentium 3 733 Mhz, 192MB Ram, Windows XP Pro

//   Target:   Platform Independent

//   Revision History:   Completed in 1 day.

// Comment: You have the right to modify the Source Code as you wish, but you must not claim this Original Source as yours.

//*****************************************************


#include <string.h>
#include <stdio.h>
#include <iostream.h>
#include <windows.h>


/*Setcolor accepts a user input number from 0 - infinite and change the font color of the command prompt
  by exiting the command prompt, the font color returns to normal*/
int main(int argc, char* argv[])
{
        //We start by initializing the necessary API
        int color;
        color = atoi(argv[1]);
        HANDLE console;
        console = GetStdHandle(STD_OUTPUT_HANDLE);

        // We first check to make sure that the user gave a command
        if (argc == 2)
        {

            //If the user enters help, a demonstration of all the colours will be shown
            if (strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "-Help") == 0 || strcmp(argv[1], "-HELP") == 0)
            {
              LABEL:
              for(color = 0; color < 99999999; color++)
              {
                 printf(" Usage: Setcolor -Help  Displays this Message\n"
                        "                 -Default Returns the Font back to normal\n"
                        "                 \"number\" Changes the color of the Font according to number\n");
                 SetConsoleTextAttribute(console, color);
                 cout << color << " This is the Help\n\n";
              }
            }
            //If the user wants to return back to normal colors without exiting the command prompt
            else if (strcmp(argv[1], "-default") == 0 || strcmp(argv[1], "-Default") == 0 || strcmp(argv[1], "-DEFAULT") == 0)
            {
             SetConsoleTextAttribute(console, 15);
            }
            //If the user gave a number, then that number is compared to see what color it matches
            else if (color <= 99999999)
            {
                SetConsoleTextAttribute(console, color);
            }
        else
            {
            //If a wrong command has been entered,  an error message is displayed
            //  and a demonstration of  all the colors is shown
              SetConsoleTextAttribute(console, 12);
              cout << "\n\nWrong Command!!!\n\n";
              goto LABEL;
            }
        }
        //In case no command has been entered, 
        else
        {
          cout << "Please enter the correct Command!!!!";
        }


        return 0;
}

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
0
 

This needs to be moved to Cplusplus language!

Member Avatar
berkcan
Newbie Poster
1 post since Aug 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

This is a nice lil' app but it is not OS independent as described, Please see source code line #3:

#include <windows.h>

Thanks,
Berk C. Celebisoy

You
Post:
Start New Discussion
Tags Related to this Article