Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8575251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:39:04+00:00 2026-06-11T19:39:04+00:00

Basically I’m making a command prompt GUI. User sees command prompt output in a

  • 0

Basically I’m making a command prompt GUI. User sees command prompt output in a rich text box, and inputs commands in a plain textbox underneath. I have succeeded in making this work, EXCEPT that to me it seems impossible to get the color information. For example, if I run a program which outputs red error text, I don’t get the color code bytes, they simply aren’t in the stream!

Here’s what I’m doing now. To start the process:

ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\Windows\System32\cmd.exe");
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardError = true;

this.promptProcess = Process.Start(startInfo);

Then I create a thread which reads from the output stream and sends that to my text box:

while (true)
{
    while (this.stream.EndOfStream) ;

    //read until there's nothing left in the stream, writing to the (locked) output box                    
    byte [] buffer = new byte[1000];
    int numberRead;
    StringBuilder builder = new StringBuilder();
    do
    {
        numberRead = this.stream.BaseStream.Read(buffer, 0, buffer.Length);
        char[] characters = UTF8Decoder.GetChars(buffer, 0, numberRead);
        builder.Append(characters);
    }
    while (numberRead == buffer.Length);

    this.writeToOutput(builder.ToString());
}

Even if I use my fancy command prompt to start an application which would output colored text, I don’t get any additional color information (not even the ANSI color codes mixed in with the text). As you can see above, I’m going to the BaseStream and reading the bytes, then decoding them into UTF8. Unfortunately, it seems that even the raw bytes do not include the original color information.

How can I get the original stream from the applications I run, without any filtering at all? I want the raw bytes so that I can do my own color parsing and present correctly-colored console output.

To clarify, I am not asking how to interpret the color codes. I just want to make them available in the stream.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:39:05+00:00Added an answer on June 11, 2026 at 7:39 pm

    Redirection of Output stream will never contains “color information”. With exception of case, when console program explicitly output text with ANSI escape sequences. But! Windows console does not support ANSI codes, so very small amount of such programs exists.

    Colors in WinAPI may be written into the console (not stream) directly only, with family of console functions like WriteConsoleOutput. Naturally, colored output may be readed from console with corresponding functions, like ReadConsoleOutput. Of course, console window must exists and not redirection must be implied.

    Same issue with unicode. Stream does not supports UTF-8, unless you ask the program write output in that codepage. But, when you read text from console (not stream) with ReadConsoleOutputW – you’ll get unicode “from the box”.

    PS. My own console emulator ConEmu (read answer on SO) reads console output via ReadConsoleOutputW.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

basically I want to validate whether or not a text box is a certain
Basically I'm wondering if I can compile code that a user inputs in a
Basically I want to check the extended permissions the user has granted my app.
Basically what I am doing is giving a user a list of terms via
Basically, I have a JTextPane to hold some text which I wish to style.
Basically I'm making a filter for my portfolio so that you can click on
Basically, I'm developing a note-taking app where the user can type as long as
Basically I'm trying to improve on the Ghosts in a Pacman game I'm making.
Basically i'm trying to build a comment system. The user looks at a photo
Basically, when I type these commands in the terminal by hand, the sift program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.