#!/usr/bin/perl -w use strict; use Win32::Clipboard; use Win32::GuiTest qw(FindWindowLike SetForegroundWindow SendKeys); # Find a specific Window my @windows = FindWindowLike(0, qr/^Microsoft Excel/, qr/^XLMAIN$/); for (@windows) { SetForegroundWindow($_); SendKeys('{PRTSCR}'); # Alt Print Screen sleep 2; } # 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, "> pscreen.bmp" or die "Couldn't open bitmap file: $!\n+"; binmode BITMAP; print BITMAP $screen; close BITMAP; __END__