Click here to Skip to main content
15,888,224 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am writing a vb.net console application running in a 120 x 32 window and am trying to take a snapshot of the window and later in the program restore it back to what it looked like at the time the snapshot was taken.

What I have tried:

I think I've got the snapshot part of the problem covered with this:
VB
Dim hConsoleOutput As IntPtr = GetStdHandle(STD_HANDLES.STD_OUTPUT_HANDLE)
Dim Buffer(3840) As CHAR_INFO
Dim BufferSize As New COORD(120, 32)
Dim BufferCoord As New COORD(0, 0)
Dim ReadRegion As New SMALL_RECT(0, 0, 119, 31)

Dim X As Boolean = (ReadConsoleOutput(hConsoleOutput, Buffer(0), BufferSize, BufferCoord, ReadRegion))
But I've not managed to write the routine to restore the window back to it's original state.

Appreciate any help with the other part of the routine!
Posted
Updated 10-Mar-17 5:52am
Comments
CHill60 10-Mar-17 10:53am    
You would have to replay all of the outputs (and potentially) inputs that went to the console window in the first place. You've captured an image, but a console window is not an "image"

So the data I captured with the ReadConsoleOutput function (text and colors) cannot be written back to the console window?

Does the WriteConsoleOutput or WriteConsoleInput functions not allow you to dump a suitably formatted (CHAR_INFO) buffer to the screen?
 
Share this answer
 
 
Share this answer
 
Comments
Member 13037218 10-Mar-17 12:55pm    
Hi Richard,

I've already seen the WriteConsoleOutput page you linked to, but I've not been able to get a routine working with that example.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900