Hi guys
Is there a way to get all the text in a console window and save it to a string variable. So once I run a Console.Clear() I can just do Console.Write(Previous Text).
Hope you can help
Get all text from console window
Page 1 of 12 Replies - 1367 Views - Last Post: 27 May 2015 - 07:55 PM
Replies To: Get all text from console window
#2
Re: Get all text from console window
Posted 27 May 2015 - 02:54 PM
I'm not sure that there is a component for that. There are ways to capture everything you send to the console, there are ways to redirect console output entirely, but I don't believe there is a way to get the currently displayed text in the console.
On the other hand, why bother? If all you want to do is replace some text, use Console.SetCursorPosition.
https://msdn.microso...(v=vs.110).aspx
You can use it to overwrite what's currently on the screen. If you were going to get everything, modify it, then write it back out, you might as well just move the cursor to the part you need to change and change it directly.
On the other hand, why bother? If all you want to do is replace some text, use Console.SetCursorPosition.
https://msdn.microso...(v=vs.110).aspx
You can use it to overwrite what's currently on the screen. If you were going to get everything, modify it, then write it back out, you might as well just move the cursor to the part you need to change and change it directly.
#3
Re: Get all text from console window
Posted 27 May 2015 - 07:55 PM
Or you could use P/Invoke to call ReadConsoleOutputCharacter().
Page 1 of 1

New Topic/Question
Reply


MultiQuote



|