I have some code:
cmdProcess = new Process();
var procStartInfo = new ProcessStartInfo( "cmd", "/k "C:\\Program Files (x86)\\Far Manager\\Far.exe"" );
procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardInput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
cmdProcess.OutputDataReceived += ( s, e ) => {
callbackFn(e.Data + "\n");
};
cmdProcess.StartInfo = procStartInfo;
cmdProcess.Start();
cmdProcess.BeginOutputReadLine();
But with this code I only can launch the process and get something, but not completely and not color. Also I tried the ReceiveConsoleOutput
function and I receive only blank buffer.
With WinAPI i can only start console and nothing else - I don't understand it well. But I'm not against WinAPI examples, because i think that my problem may be solved with it.
I would be grateful if anyone can help me.
P.S. I'm sorry for bad english.
You talk about two different things. ConEmu and the original console has color support, but this is achieved via the console buffer API (here is a complete C# library). The console supports not just coloring but cursors and mouse, too; however, none of them have anything to do with the standard output.
But if you want to receive color information in the standard output, you can use the ANSI escape sequences, which is a standard in terminal communication (and this is used for ANSI graphics art, too), supports coloring and cursor positioning as well and can be encoded as a character stream.
But if the process you call does not dump ANSI sequences, (cmd
does not do this) you will not receive any color information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With