Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Here is some code to do the screen capture part:
    #!/usr/bin/perl -w

    use strict;
    use Win32::Clipboard;
    use Win32::GuiTest qw(FindWindowLike SetForegroundWindow SendKeys);

    # Find an open Word document
    my @windows = FindWindowLike(0, qr/Microsoft Word/);

    # Bring Word to the foreground (with focus)
    for (@windows) {
        SetForegroundWindow($_);
        SendKeys('%{PRTSCR}'); # Alt Print Screen
    }

    # Get the image from the clipboard.
    my $screen = Win32::Clipboard::GetBitmap()
                 or die "No image captured: $!\n";

    # Print the image to a file.
    open    BITMAP, "> screen.bmp" or die "Couldn't open bitmap file: $!\n";
    binmode BITMAP;
    print   BITMAP $screen;
    close   BITMAP;

    __END__