• /Capture DOS Screen Text Programmatically

    From BotSearch@1:3407/4.1 to Alejandro Pelaez on Sunday, May 13, 2001 18:39:36
    {[Google ]}

    {Advanced Groups Search}
    {Groups Help}
    Search all groups Search the Web
    {Click here} for information about upcoming improvements to this beta version of Google's Usenet search.
    Messages from the thread "Capture DOS Screen Text Programmatically" Messages 1 - 9 of 9.
    Message 1 in thread
    From: {Dayang Dai} ({ddai@houston.rr.com})
    Subject: Capture DOS Screen Text Programmatically
    Newsgroups: {microsoft.public.platformsdk.gdi}, {microsoft.public.platformsdk.ui}, {microsoft.public.sbk.windows9x}, {microsoft.public.sbk.windowsnt}, {microsoft.public.win32.programmer.gdi}, {microsoft.public.win32.programmer.kernel}, {microsoft.public.win32.programmer.ui}, micro
    Date: 2000/10/14

    I am running on NT. I need to write a program to capture the Screen Display
    of a DOS application. Using the "Print Screen" key will not work for me because it is a manual process. (Can I do Print Screen to Clipboard programmatically?). Redirect the DOS App's standard output will not work
    for me neither because the result is on the screen (like using cprintf() in that DOS app).

    Do I need to deal with the Virtual DOS Machine?

    Also, Can I use SendMessage( hWnd, xx, xx ) to send key strokes to the DOS application?

    Basically I want to programmatically control a DOS application. Which direction should I go?

    Please help and many thanks

    Dayang Dai

    dayangd@yahoo.com




    Message 2 in thread
    From: {Dimitris Tripakis} ({dtrip@ics.forth.gr})
    Subject: Re: Capture DOS Screen Text Programmatically
    Newsgroups: {microsoft.public.platformsdk.gdi}, {microsoft.public.platformsdk.ui}, {microsoft.public.sbk.windows9x}, {microsoft.public.sbk.windowsnt}, {microsoft.public.win32.programmer.gdi}, {microsoft.public.win32.programmer.kernel}, {microsoft.public.win32.programmer.ui}, micro
    Date: 2000/10/15

    (Can I do Print Screen to Clipboard programmatically?).

    If you do
    GetDC(NULL);
    you will get the HDC of the entire screen.

    From there, you can do a BitBlt( ) from the screen to
    a compatible DC you have created (probably an HBITMAP,
    created by CreateCompatibleBitmap() )

    You can read the bytes of this HBITMAP using :
    GetObject()

    ..or you could read directly from the screen using
    GetPixel()

    I would personally choose the first way, blit an instance
    of the screen to a bitmap and work on this one. Otherwise,
    if you work on the screen, it might change in time, and
    this could cause problems....

    Note that you need OCR code to extract the text from this,
    since what you will end up with is a "bitmap"...

    Dimitris



    Message 3 in thread
    From: {gu} ({NOSPAMREMOVEgutrageser@debitel.net})
    Subject: Re: Capture DOS Screen Text Programmatically
    Newsgroups: {microsoft.public.platformsdk.gdi}, {microsoft.public.platformsdk.ui}, {microsoft.public.sbk.windows9x}, {microsoft.public.sbk.windowsnt}, {microsoft.public.win32.programmer.gdi}, {microsoft.public.win32.programmer.kernel}, {microsoft.public.win32.programmer.ui}, micro
    Date: 2000/10/15


    Win32 offers special functions for controlling the console. You can use ReadConsoleOutput() to get the characters on the console if you just need a hardcopy of the text.

    For really controlling a DOS application, you have to write a shell
    programm, which creates three pipes. Then you are able to start your
    programm with CreateProcess() and redirecting stdin, stdout and stderr to
    your pipes. And in your shell programm you are able to handle stdout and
    even put it to the console (using GetStdHandle() and WriteConsole()).

    gu



    Message 4 in thread
    From: {Axel K÷ster} ({akoester@hstnet.de})
    Subject: Re: Capture DOS Screen Text Programmatically
    Newsgroups: {microsoft.public.platformsdk.gdi}, {microsoft.public.platformsdk.ui}, {microsoft.public.sbk.windows9x}, {microsoft.public.sbk.windowsnt}, {microsoft.public.win32.programmer.gdi}, {microsoft.public.win32.programmer.kernel}, {microsoft.public.win32.programmer.ui}
    Date: 2000/10/16


    "Dayang Dai" <ddai@houston.rr.com> wrote

    I am running on NT. I need to write a program to capture the Screen
    Display
    of a DOS application. Using the "Print Screen" key will not work for me because it is a manual process. (Can I do Print Screen to Clipboard programmatically?).

    Hello Dayang Dai,

    I suggest to use "Print Screen". You can use keybd_event() with VK_PRINT
    as parameter to copy the DOS screen into the clipboard.. The DOS application must be in foreground (receiving the keyboard input). After that you can usethe OpenClipboard(), GetClipboardData(), ... to get the content of the
    clipboard.
    You get only the text (neither graphic nor the text attributes).

    Regards,
    Axel




    Message 5 in thread
    From: {Jim Barry} ({jim.barry@bigfoot.com})
    Subject: Re: Capture DOS Screen Text Programmatically
    Newsgroups: {microsoft.public.platformsdk.gdi}, {microsoft.public.platformsdk.ui}, {microsoft.public.sbk.windows9x}, {microsoft.public.sbk.windowsnt}, {microsoft.public.win32.programmer.gdi}, {microsoft.public.win32.programmer.kernel}, {microsoft.public.win32.programmer.ui}
    Date: 2000/10/16


    Axel K÷ster wrote:

    I suggest to use "Print Screen". You can use keybd_event() with
    VK_PRINT as parameter to copy the DOS screen into the clipboard..
    You get only the text (neither graphic nor the text attributes).

    Really? I get only a full-screen bitmap (or a window-sized bitmap if the Alt key is held down).

    Cheers,

    - Jim


    Message 6 in thread
    From: {Dayang Dai} ({ddai@houston.rr.com})
    Subject: Re: Capture DOS Screen Text Programmatically
    Newsgroups: {microsoft.public.platformsdk.gdi}, {microsoft.public.platformsdk.ui}, {microsoft.public.sbk.windows9x}, {microsoft.public.sbk.windowsnt}, {microsoft.public.win32.programmer.gdi}, {microsoft.public.win32.programmer.kernel}, {microsoft.public.win32.programmer.ui}, micro
    Date: 2000/10/16

    Thank you everybody for the input. I end up use GU's suggestion. I opened
    a console screen and then use CreateProcess() to load my real DOS app.
    Then I use WriteConsoleInput() to feed the keystrokes (even funtion keys).
    For reading screen text, I use the ReadConsoleOutput() the read back the
    screen output. It is great. Many thanks

    Dayang Dai.

    gu <NOSPAMREMOVEgutrageser@debitel.net> wrote in message {news:#skwPpnNAHA.216@cppssbbsa02.microsoft.com}...
    Win32 offers special functions for controlling the console. You can use ReadConsoleOutput() to get the characters on the console if you just
    need a
    hardcopy of the text.

    For really controlling a DOS application, you have to write a shell
    programm, which creates three pipes. Then you are able to start your
    programm with CreateProcess() and redirecting stdin, stdout and stderr
    to
    your pipes. And in your shell programm you are able to handle stdout and
    even put it to the console (using GetStdHandle() and WriteConsole()).

    gu





    Message 7 in thread
    From: {Axel K÷ster} ({akoester@hstnet.de})
    Subject: Re: Capture DOS Screen Text Programmatically
    Newsgroups: {microsoft.public.platformsdk.gdi}, {microsoft.public.platformsdk.ui}, {microsoft.public.sbk.windows9x}, {microsoft.public.sbk.windowsnt}, {microsoft.public.win32.programmer.gdi}, {microsoft.public.win32.programmer.kernel}, {microsoft.public.win32.programmer.ui}
    Date: 2000/10/17

    "Jim Barry" <jim.barry@bigfoot.com> wrote:

    Axel K÷ster wrote:

    I suggest to use "Print Screen". You can use keybd_event() with
    VK_PRINT as parameter to copy the DOS screen into the clipboard..
    You get only the text (neither graphic nor the text attributes).

    Really? I get only a full-screen bitmap (or a window-sized bitmap if the
    Alt
    key is held down).

    Cheers,

    - Jim

    This only work in fullscreen text mode :-(
    Sorry, this was my fault.

    Thanks,
    Axel



    Message 8 in thread
    From: {Jim Barry} ({jim.barry@bigfoot.com})
    Subject: Re: Capture DOS Screen Text Programmatically
    Newsgroups: {microsoft.public.platformsdk.gdi}, {microsoft.public.platformsdk.ui}, {microsoft.public.sbk.windows9x}, {microsoft.public.sbk.windowsnt}, {microsoft.public.win32.programmer.gdi}, {microsoft.public.win32.programmer.kernel}, {microsoft.public.win32.programmer.ui}
    Date: 2000/10/17


    Axel K÷ster wrote:

    This only work in fullscreen text mode

    Ah, right you are.

    Cheers,

    - Jim



    Message 9 in thread
    From: {Jonathan de Boyne Pollard} ({J.deBoynePollard@tesco.net})
    Subject: Re: Capture DOS Screen Text Programmatically
    Newsgroups: {microsoft.public.platformsdk.gdi}, {microsoft.public.platformsdk.ui}, {microsoft.public.sbk.windows9x}, {microsoft.public.sbk.windowsnt}, {microsoft.public.win32.programmer.gdi}, {microsoft.public.win32.programmer.kernel}, {microsoft.public.win32.programmer.ui}, {comp.os.ms-windows.programmer.nt.kernel-mode}
    Date: 2000/10/17


    I am running on NT. I need to write a program to capture the
    Screen Display of a DOS application.

    Because of a programming tradition on Microsoft operating systems that
    goes all of the way back to the earliest versions of MS-DOS, there is no
    one single way to capture the output or control the input of a textual application.

    On Windows NT, the case of DOS applications is actually a subset of the
    more general case of "console mode" applications, because DOS
    applications run as coroutines within a Win32 process (NTVDM) that
    translates their I/O to Win32 equivalents.

    There are two classes of console mode applications. The important
    difference between the two is whether they read from and write to their standard input and standard output in "glass TTY" fashion using
    ReadFile() and WriteFile() (what Win32 terms "high-level console I/O"),
    or whether they use "random access" APIs such as WriteConsoleOutput()
    (what Win32 terms "low-level console I/O"). Translating this to DOS
    terms: DOS programs that use INT 21h to read from and write to their
    standard input and standard output are in the former class; and DOS
    programs that use INT 10h or that write directly to video memory are in
    the latter class.

    To capture the output and control the input of programs that use
    "low-level console I/O", one sits in a loop whilst the child process is executing, continuously monitoring the contents of the console screen
    buffer using ReadConsoleOutput() and sending any keystrokes using WriteConsoleInput().

    There are several problems with this design. One minor problem is that
    it doesn't cope at all well with Win32 programs that take full advantage
    of the features of the Win32 low-level console paradigm and use
    alternate console screen buffers for their output. A more major problem
    is that because it uses polling (Win32 not providing any handy event
    mechanism to latch on to so that the monitor could know when the buffer
    has been modified) it is always going to be both unreliable and
    expensive. It is unreliable in that depending from the relative
    scheduling priorities of the various processes, something which is going
    to vary dynamically with system load, it may well be the case that the
    child program may be able to generate reams of output that the
    monitoring process will simply miss because its console monitoring
    thread won't be scheduled to run often enough. It is expensive in that
    if the child process happens not to generate any output for a while, the monitoring process is going to consume CPU time needlessly.

    To capture the output and control the input of programs that use
    "high-level console I/O", one redirects their standard input and
    {Read the rest of this message...} (32 more lines)


    {Google Web Directory} - {Cool Jobs} - {Advertise with Us} - {Add Google to Your Site} - {Google in your Language} - {All About Google}
    ⌐2001 Google

    --- BotSearch
    * Origin: ECHO\WILDCATS WILDCAT (1:3407/4.1)