[RESOLVED] Console.UpdateText?
I am sure some of you know of Handbrake, and it's CLI. Now I am trying use this CLI, and read its standard output to get the progress. But the problem is, they are not using Console.WriteLine to write the progress in their CLI, they are using something else :confused:
If I read the standardoutput I only get this line:
Encoding task 1 of 2 blabla 0.00%
But if I don't redirect outputs or set CreateNoWindow to true, so the CLI shows up in its own window, I can see that the progress is ticking.
What I wonder is if there exist anything like Console.UpdateText, where you don't write a newline, you just edit the last written one.
And if so, how to read it?:ehh:
I am reading with this code:
Code:
string str;
while ((str = prc.StandardOutput.ReadLine()) != null)
{
Console.Write(str);
}
Re: [RESOLVED] Console.UpdateText?
Whew this harkens back to my old DOS programming days.
In the DOS console (not the CMD Shell - they're different) one can send BIOS Interop codes to move the cursor around the shell. You can not only rewrite the line you're on - I used to write information at the top line and bottom line of the screen with every update and then put the cursor back to where it started.
Those were the days! (I wrote in Fortran then!!)
The escape characters you would use for that are listed here, but are a bit cryptic to puzzle out:
http://local.wasp.uwa.edu.au/~pbourk...formats/ascii/
(Scroll down to "ANSI Standard (X3.64) Control Sequences For Video Terminals And Peripherals In Alphabetic Order By Mnemonic")
The escape sequence to set a position would be:
Code:
//Code not tested
//Let's set the position to 3, 12
byte HorizontalOffset = (byte) 3;
byte VerticalOffset = (byte) 12;
char[] MovePosition = {27, '[', HorizontalOffset, ';', VerticalOffset, 'H'};
Console.Write(MovePosition);
Though I can't test this right now (about to be away from the computer). And it may not work in the console at all anymore.
Re: [RESOLVED] Console.UpdateText?
Haha. They saw me coming. The code above doesn't work (it just displays garbage which is what I expected)
... but the following does work:
Code:
Console.SetCursorPosition(3, 12);
Console.Write("Test");
Console.ReadKey();
Talk about elephant gun and fly...
Re: [RESOLVED] Console.UpdateText?
To extend the example, this writes " Well?" then backs up, overwrites the space with an "Sw" (Making it "Swell?") and returns the input back to where it was (after the question mark).
Code:
Console.WriteLine("Test Line");
Console.Write(" Well?");
int Horizontal = Console.CursorLeft;
int Vertical = Console.CursorTop;
//Upper Left is 0, 0
Console.SetCursorPosition(0, Vertical);
Console.Write("Sw");
Console.SetCursorPosition(Horizontal, Vertical);
Console.ReadKey();
Re: [RESOLVED] Console.UpdateText?