tags:

views:

568

answers:

4

Hi! Just wondering if there is any way (in C) to get the contents of the console buffer, preferably as some kind of char array. It is going to be written to a file, so if I am missing out on something stupid that will do exactly that, then point it out. It can be Windows-specific. I am using MinGW (gcc 3.4.5).

Thanks in advance.

A: 

If it's the screen in a command window, then potentially no, or no easy way. You could hack at Windows events to select-all, copy, and read the clipboard.

Charlie Martin
+3  A: 

I think you need to take a look at win32 console functions for example GetStdHandle(), ReadConsoleOutput(), WriteConsoleOutput etc.

SDX2000
OK, I'll check that out now!
Lucas Jones
+2  A: 

In Win32, ReadConsoleOutput:

Reads character and color attribute data from a rectangular block of character cells in a console screen buffer, and the function writes the data to a rectangular block at a specified location in the destination buffer.

Roger Lipscombe
Thanks for the link! :-) I would vote you up but I just joined.
Lucas Jones
A: 

Download mingw-readline

And look GNU Readline

rl_line_buffer
plan9assembler