http://www.perlmonks.org?node_id=954150

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

Hi All,

I am trying to take printscreen and save it is as an image file. However i get image file in bmp format using Win32::Clipboard module.

Is it possible to save image in TIFF format?.

Thanks in advance

#!/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__