Re: Win32 Screenshot/Screencapture with perl

2003-02-16 Thread Roland Moriz
Hi Michael,

At 21:46 16.02.2003, michael higgins wrote:
>Roland Moriz wrote:
>>Hi,
>>I need to do screenshots with perl on win32. The only possible way i found
>>is to simmulate they "printscrn" key and then read the clipboard. On the London.pm
>
>I don't know about that, but I remembered cribbing this from the list, which does 
>what you ask:
[...]

works great. thank you very much :-)



with kind regards,
Mit freundlichen Gruessen,

Roland Moriz
--
http://www.roland-moriz.de/
[EMAIL PROTECTED] ~ [EMAIL PROTECTED] ~ [EMAIL PROTECTED]

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Win32 Screenshot/Screencapture with perl

2003-02-16 Thread michael higgins
Roland Moriz wrote:

Hi,

I need to do screenshots with perl on win32. The only possible way i found
is to simmulate they "printscrn" key and then read the clipboard. On the London.pm


I don't know about that, but I remembered cribbing this from the list, 
which does what you ask:

#!perl -w --

use strict;
use Win32::API;

my $push_key = new Win32::API("user32", "keybd_event", [qw(I I N P)], 
'V') or
  die "keybd_event: " . Win32::FormatMessage (Win32::GetLastError ());

use constant VK_SNAPSHOT => 0x2C;
use constant KEYEVENTF_EXTENDEDKEY => 0x01;
use constant KEYEVENTF_KEYUP => 0x02;

my $bVk = VK_SNAPSHOT;
my $bScan = 0x01;# backwards from docs: 1=screen; 0=window
# PRINT SCR scan code for 102 keybd => E0 2A E037
# 2A or 37 gets window
my $dwFlags = KEYEVENTF_EXTENDEDKEY;
my $dwExtraInfo = 0;

$push_key->Call($bVk, $bScan, $dwFlags, 0); # simulate a "printscrn" key 
press

# the release seems to not be needed
#$dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP;
#$push_key->Call($bVk, $bScan, $dwFlags, 0); # & release

use Win32::Clipboard;

my $file = 'screendump.bmp';
my $image = Win32::Clipboard::GetBitmap();
open BITMAP, ">$file" or die "Error creating $file: $!";
binmode BITMAP;
print BITMAP $image;
close BITMAP;

__END__



--


 ^ ^
<-|->
 (.)__ the world is a big box of paints.
__ __  and others, the canvas we're dealt.
 | | -  XTC
_/ \_

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs