Thread View: comp.os.ms-windows.programmer.win32
3 messages
3 total messages
Started by lars
Mon, 11 Oct 1999 00:00
Grab Screen from active DOS/console App. ?
Author: lars
Date: Mon, 11 Oct 1999 00:00
Date: Mon, 11 Oct 1999 00:00
26 lines
1539 bytes
1539 bytes
Hi, I want to grab the textcontent of an active DOS box. - what i DONT want is a solution that "pipes" data another way - like: dir > data.dat since this wont work with an active application - ex EDIT.EXE or another program running until user exits the program. What i would like is to "poll" the DOS box from my application - and get the ex. 80*25 characters - and ex. display this in another way in my GUI application. Can anyone tell me if this is possible ? - im using CreateProcess to launch the external application, the dos application will always be "windowized" - not a fullscreen box. I have looked at AllocConsole....but well...i dont really get the idea of this. Hope this is clear and someone can help me, thanks. Regards, Lars
Re: Grab Screen from active DOS/console App. ?
Author: Zhang
Date: Mon, 11 Oct 1999 00:00
Date: Mon, 11 Oct 1999 00:00
12 lines
1278 bytes
1278 bytes
>Hope this is clear and someone can help me, thanks. It's clear enough for me to understand you question. The hard nutt to crack is that the text itself has to be captured, and not just the graphical window. I don't know DOS-programming that well, but there ought to be a function that "captures" the console's text-buffer. Else you should be able to locate it in memory somehow (thy WinHack, and the search for one of the words displayed in the console. That's all I can possibly think of... Zhang
Re: Grab Screen from active DOS/console App. ?
Author: Klasens
Date: Wed, 13 Oct 1999 00:00
Date: Wed, 13 Oct 1999 00:00
91 lines
3362 bytes
3362 bytes
lars <lti@delfi.dk> schreef in berichtnieuws
7tsso1$94v$1@news.inet.tele.dk...
> Hi,
>
> I want to grab the textcontent of an active DOS box.
>
> - what i DONT want is a solution that "pipes" data another way - like:
>
> dir > data.dat
>
> since this wont work with an active application - ex EDIT.EXE or another
> program running until user exits the program.
>
> What i would like is to "poll" the DOS box from my application - and get
the
> ex. 80*25 characters - and ex. display this in another way in my GUI
> application.
/////////////////////////////////
#include <windows.h>
VOID main(void)
HANDLE hStdout;
SMALL_RECT srctReadRect;
CHAR_INFO chiBuffer[160]; // [2][80];
COORD coordBufSize;
COORD coordBufCoord;
BOOL fSuccess;
/*
* Get a handle of the STDOUT screen buffer to copy from and
*/
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdout == INVALID_HANDLE_VALUE){
/*error code*/
}
/* Set the source rectangle. */
srctReadRect.Top = 0; /* top left: row 0, col 0 */
srctReadRect.Left = 0;
srctReadRect.Bottom = 1; /* bot. right: row 1, col 79 */
srctReadRect.Right = 79;
/* The temporary buffer size is 2 rows x 80 columns. */
coordBufSize.Y = 2;
coordBufSize.X = 80;
/*
* The top left destination cell of the temporary buffer is
* row 0, col 0.
*/
coordBufCoord.X = 0;
coordBufCoord.Y = 0;
/* Copy the block from the screen buffer to the temp. buffer. */
fSuccess = ReadConsoleOutput(
hStdout, /* screen buffer to read from */
chiBuffer, /* buffer to copy into */
coordBufSize, /* col-row size of chiBuffer */
coordBufCoord, /* top left dest. cell in chiBuffer */
&srctReadRect); /* screen buffer source rectangle */
if (! fSuccess){
/*error code*/
}
}
/////////////////////////////////
/////////////////////////////////
typedef struct _CHAR_INFO {
union {
WCHAR UnicodeChar;
CHAR AsciiChar;
} Char;
WORD Attributes;
} CHAR_INFO, *PCHAR_INFO;
> Can anyone tell me if this is possible ? - im using CreateProcess to
launch
> the external application, the dos application will always be
"windowized" -
> not a fullscreen box.
> I have looked at AllocConsole....but well...i dont really get the idea of
> this.
AllocConsole can't start a application. CreateProcess is the one you need.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads