Windows Screenshot from perl





7
Date Submitted Tue. Mar. 7th, 2006 4:34 PM
Revision 1 of 1
Helper digitaljunkie
Tags Clipboard | Perl | Screenshot | Win32::API
Comments 1 comments
This requires Win32::API, and Win32::Clipboard.
Only works on Win32 Platforms. Only really tested on Win2000, and WinXP.

Not meant to be an be all, end all, but it's a start.

Have fun!


use strict;
use Win32::API;
use Win32::Clipboard;

my $output_file = "ss1.bmp";

my $key = new Win32::API("user32", "keybd_event", 'IINP', 'V');
die "Can't import user32.dll: $!\n" if (! $key);

my $clip = Win32::Clipboard();

# Empty the Clipboard
$clip->Empty();

# Press the Prntscrn key!!
$key->Call(0x2C, 0x45, 0x01, 0); # Press
$key->Call(0x2C, 0x45, 0x03, 0); # & Release

# Wait for the Image to fill the clipboard
$clip->WaitForChange();

my $image = $clip->GetBitmap();

open (BITMAP, "> $output_file");
binmode BITMAP;
print BITMAP $image;
close(BITMAP);

 

Steve Wilder

Steve Wilder
Technology Resource Group
unpack "u", qq(1

Comments

Comments Interesting
Sun. Mar. 12th, 2006 10:26 AM    Helper Scriptsentials

Voting