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

Hi, I have a list of websites that I would like to automatically capture the screen and save. I've used Win32::OLE/WWW::IE::Mechanize to load each site in IE. Is there a way to automate "printscreen", and then paste the result image from the clipboard into a Word document? Thanks.

Replies are listed 'Best First'.
Re: printscreen and clipboard using perl
by mpolo (Chaplain) on Oct 28, 2004 at 18:17 UTC
    My first guess was to use Win32::Clipboard. That will let you copy stuff to the clipboard and call it back. However, Win32::Screenshot will get you a PNG of the screen, which you can then use as you will. With Win32::OLE you can control Word, presuming you know the right methods and objects.
Re: printscreen and clipboard using perl
by tilly (Archbishop) on Oct 28, 2004 at 21:07 UTC
    If you find no other solution, in the past I've used Win32::OLE to tell IE to print the document. If it is set up to print to a file that'll print to a postscript file which you might be able to get Word to import.

    Warning: that route is definitely hackish. If someone goes and changes the print preferences, everything will break horribly. (I had reasons to do things this way, but also was very happy when the day came that I could tear up this solution and replace it with a better one.)

Re: printscreen and clipboard using perl
by zentara (Cardinal) on Oct 29, 2004 at 11:33 UTC
    I don't know if this will help you on win32, but on linux, you can use the command xwininfo to get the window id of an application, then use ImageMagick's "import -window windowid some.jpg" to grab it's screenshot. I havn't tried it, but I believe ImageMagick is available for win32. Just a thought from linux-land in case you need other ideas. :-)

    I'm not really a human, but I play one on earth. flash japh