Changing the color palette on the fly

May 20, 2008
11,378
98
Syracuse, NY, USA
My CONHOST.EXE is nothing special ... just up-to-date.

Code:
TCC 28.00.12 x64
Microsoft Windows 10 Pro for Workstations
10.0.19043.1165 (2009, 21H1)

There's an escape sequence that will change a color palette entry on the fly, and update the console. The syntax is

Code:
ESC]4;i;rgb:r/g/bESC

where i is the color index and r,g, and b are hex (0-FF) values for the new color.

Before:

1630634426086.png


After:

1630634652495.png
 
May 20, 2008
11,378
98
Syracuse, NY, USA
I mentioned in the support forum that I didn't have the sequence terminator right (no fault of mine). It worked as it was but caused problems. The sequence should have a \ at the end, like this.

Code:
ESC]4;i;rgb:r/g/bESC\

You can also use

Code:
ESC]4;i;rgb:r/g/b%@char[0x9C]

If anyone's interested, the sequence terminator is called "ST" (for "string terminator"). ESC\ is the 7-bit version of ST and %@char[0x9C] is the 8-bit version. I guess these things go back to a time when some systems/terminals couldn't deal with 8-bit characters.
 
Similar threads
Thread starter Title Forum Replies Date
vefatica Win10 inactive window title bar color T&T - Miscellaneous 0

Similar threads