Console Palette Changer
by the derelict

Console Palette Changer is a utility which lets a user edit and load customized color palettes for the Windows console (formerly called the DOS prompt).  This utility is especially beneficial when used with a color directory lister such as my NDIR utility, the Cygwin ls utility, or any other similar tool; such color utilities show off the palettes in use in the various color schemes.

There are two programs included in this package;
  • Console Palette Changer - A Windows utility which lets you preview, edit, and save palette files, as well as opening new consoles with your selected palette.  Note that, while this utility is very useful for creating and editing the palette files, it's easier to load an existing palette into a console using the consattr utility which is discussed below.
  • consattr - A console (i.e., DOS) utility which allows one to load an existing palette into the current console.  It does not provide any editing options, but it does change the current console.  You can even put a consattr in your autoexec.bat (or 4start.bat for 4NT users), to start up a console with your desired palette!!

    Windows Vista/7 note (01/27/10):
    Although the Windows utility in this package works, unfortunately the console version does not.  I need to do some further research to figure out what is wrong.


    History

    Back in late 1990, PC Magazine published a cute utility called prism, which allowed the user to re-define any of the 16 standard DOS colors, using the 24-bit VGA palette.  You could then save your customized palette in a file which you could later load back into memory using the same utility.  Unfortunately, prism doesn't work with windowed consoles.  It still works with consoles which are used in full-screen mode, but most people who use consoles don't use them that way.  Also, prism can only be used to set the palette for one console at a time.


    Console Palette Changer

    cpc main dialog


    Console Palette Changer will enable you to open as many consoles as you wish, each with a different palette if you desire!!  You can also edit individual colors within a palette (by clicking on the numbered, colored square at the bottom of the dialog), and save your new palette under a different name.

    This program is released as freeware.  The program and its source code may be included on any distribution site or other media without contacting me, though emails are always welcome.

    Download Console Palette Changer ( Current version: 1.04 ).  This package also includes the console utility.  The source code for these packages is available later on this page.

    There is no installation file.  Just unzip the archive into a directory somewhere, and run console_attr.exe.  If you unzip it in a directory that is in your PATH, you can run the console utility consattr and change your palette any time you wish!!



    Screen Shots of consoles using CPC palettes

    HawaiiSultry
    Hawaii Sultry
    IrelandBrownie
    Ireland Brownie

    consattr - a console utility

    This is a console (i.e., DOS) utility which allows one to load an existing palette into the current console from the command line.  consattr does not provide any editing options, but it does change the current console!!

    The command line for consattr is:
    Set Console Attributes, Version 1.02
    Usage: consattr [options] palette_file
    Options:
     -bB.B - set brightness level (default is 3.1)
    
     -xcpath - update a Console2 xml config file in directory [cpath].
       If cpath is omitted, /console2 is used.
    
    If palette_file does not contain a path, I will look for
    the file in the 'palettes' directory below the location
    where the executable file is found.
    Also, if the .plt extension is not included in palette_file,
    .plt will be appended.
    So, for example, if you extract the zip file somewhere which is in your path, such as c:\windows, then the command
    consattr derelict
    will load the derelict palette file into the current console.

    The reason for the brightness setting is that palette files which were created for the DOS environment tend to be very faint when viewed in windowed consoles. I've found that brightness of 3.1 (the default setting) makes the screen look much like it did in a full-screen console. YMMV, of course, which is why this option is included.

    This utility works with WinXP CMD.EXE, JPSoft's 4NT, and current versions of the Cygwin Bash utility.  It does *not* work in JPSoft's TCI console(s), unfortunately. It should work on Win2K, but I don't know about any earlier operating systems.


    consattr and the console2 tabbed console

    Effective with version 1.02, consattr now supports setting the console attributes for the open-source tabbed console utility console2 , from SourceForge.

    The simplest way to use this option is to extract the console2 utility to a directory named console2, directly below the location where consattr is stored, and add the -x option to the command line. Extracting the zip file will create this console2 directory for you, which simplifies this process.

    However, as always, there's a catch.  Because console2 over-writes its configuration file on exit, you can't run this FROM a console2 session!!  Instead, you need to use this sequence:
    1. close console2
    2. open a normal console, and run the consattr -x command
    3. open console2, and it will be then be using the palette that you specified.

    I know, this is annoying, I'll continue to work on improving this interface (since I'm now using console2 myself - it's really cool!!). Unfortunately, I don't get the sense that I'm going to get much support from the console2 author on this issue, and I don't have the tools required to build it myself.



    Source Code

    for these utilities

    The C/C++ source code for this program is available here.  It is also freeware, you may use this code in any way you wish, modify it to your heart's content, and distribute it any way you wish.  The only thing I ask is that you retain a reference to this site, at least in the source code for your modified program.

    Download WIN32  source code  here.  This package is compiled with the free C++ compiler from
    MinGW - Minimalist GNU for Windows.

    Note: the Mingw compiler environment does not contain the files required for calling the html help system. I am enclosing them here:
    Download html help files here
    Put htmlhelp.h in /mingw/include
    Put libhtmlhelp.a in /mingw/lib
    
    That *should* be all that is needed to link the help file to the program.

    Later note: For some reason, mingw cannot be used to build the console utility consattr... the program is generated just fine, but when you run it, it closes the console window!! No errors are generated, I don't know what is going wrong. The source archive includes a batch file bld.bat which can build a working consattr using Visual C++ 6.


    technical references

  • prism
    Although prism is the conceptual basis for this utility, the source code was never released, besides which Pc Magazine didn't permit their utilities to be publicly distributed, even when they did provide source.  As a result, these utilities have been developed entirely from scratch, without any reference to code, algorithms, or anything else from prism.

  • consattr
    I am deeply indebted to James Brown at Catch22 Productions for teaching me how to load a palette into the current console.  It's a top-secret method which isn't documented anywhere on the internet, at least if you don't already know the names of the relevant functions and data structures.  On the Catch22 Sourcecode page, partway down the page there is SetConsolePalette which does the job beautifully!!!  All I added was the user interface to specify the desired palette file.

  • Console Palette Changer
    This Windows utility was written a few months ago, before I had discovered Catch22's solution. I had figured out where the console palettes were stored in the registry (by defining a color of my own, then searching the registry to see where it turned up).  So I wrote this utility to read the palette files, handle editing, and write the data into the registry ColorTable entries... only to discover that those registry entries don't even get used until the machine is rebooted, at least when I opened the console from a shortcut.  However, I learned by accident that if I opened cmd.exe from the Start:Run menu, the registry colors were used immediately... so I added the Launch Console button, which launches the specified command processor from the Run dialog. Whew, alot of work, but it works!!