Chad_MacArthur has asked for the wisdom of the Perl Monks concerning the following question:

I need to capture the screen output from a script into a file.
The script requires user interaction and i wish to capture this as well. I know with unix you can use the script command but i'm not to sure with windows.
Thanks mate
Chad
  • Comment on Capture Screen Output on Windows into a File

Replies are listed 'Best First'.
Re: Capture Screen Output on Windows into a File
by BrowserUk (Patriarch) on Apr 29, 2004 at 04:30 UTC

    If your just after capturing the text output from a script, cmdline redirection is the way to go, but if your trying to capture a graphical (bitmap) representation, then this Re: capture what's on the screen snippet from a while ago may be what you are looking for.

Re: Capture Screen Output on Windows into a File
by Koosemose (Pilgrim) on Apr 29, 2004 at 03:38 UTC

    Hmm... well I don't know about mimicing script's methods, but if you just want to send whatever the program prints you can just do simple redirection (ie. perl script.pl > holdme). But, if it's an interactive program you'll have no idea what it's asking you. Perhaps if you could provide more details on the nature of the program who's output you want to capture and its purpose, perhaps some of the good monks could suggest alternate solutions. Or you could google around for a win port of script (with a name like that it may be tricky though)

    Just Another Perl Alchemist
Re: Capture Screen Output on Windows into a File
by jdporter (Paladin) on Apr 29, 2004 at 03:41 UTC
    Is simply redirecting the output into a file not sufficient?
Re: Capture Screen Output on Windows into a File
by gellyfish (Monsignor) on Apr 29, 2004 at 11:02 UTC

    If you are in a position to write an intermediate program which is like script then you might find this article useful.

    The bottom line though is that this appears to be somewhat of a holy grail among windows programmers due to the nature of the Console IO there

    /J\

Re: Capture Screen Output on Windows into a File
by McMahon (Chaplain) on Apr 29, 2004 at 14:29 UTC
    Would qx// do what you need?
Re: Capture Screen Output on Windows into a File
by deadkarma (Monk) on Apr 29, 2004 at 23:47 UTC
    You can take a screenshot to the clipboard on most Windows machines with the PrintScreen key.

    Maybe there is a way you can somehow simulate the 'PrintScreen' key, and then read the contents of the clipboard.

    Or maybe direct the user to press the 'PrintScreen' key themselves, and then read the contents of the clipboard.