Win32::Capture - Capture screen and manipulate it with Win32::GUI::DIBitmap instance. |
Win32::Capture - Capture screen and manipulate it with Win32::GUI::DIBitmap instance.
use Win32::Capture;
$image = CaptureScreen(); # Capture whole screen. $image->SaveToFile('screenshot.png');
# or
$image = CaptureRect($x, $y, $width, $height); # Capture a portion of window. $image->SaveToFile('screenshot.png');
# or
@hwnds = FindWindowLike('CPAN'); # Invoke helper function to get HWND array.
if ($#hwnds<0) { print "Not found"; } else { foreach (@hwnds) { my $image = CaptureWindowRect($_, 2, 0, 0, 400, 300); $image->SaveToFile("$_.jpg", JPEG_QUALITYSUPERB); } }
The purposes of package are similar to Win32::Screenshot. But you can manipulate screen shot image with Win32::GUI::DIBitmap instance.
All of these functions are returning a new Win32::GUI::DIBitmap instance on success or undef (a.k.a undefined variables) on failure. All functions are exported by default.
CaptureScreen()
Set $dur to wait for a while before capturing.
TIPS: Invoke FindWindowLike($text)
helper function to find $hWND value.
$flag = 0 : Entire window will be captured (with border) $flag = 1 : Only client window region will be captured.
TIPS: Invoke FindWindowLike($text)
helper function to find $hWND value.
FindWindowLike($text)
@hwnds = FindWindowLike('CPAN');
if ($#hwnds<0) { print "Not found"; } else { foreach (@hwnds) { my $image = CaptureWindowRect($_, 2, 0, 0, 400, 300); $image->SaveToFile("$_.jpg", JPEG_QUALITYSUPERB); } }
The $text argument stands for a part of window title. FindWindowLike will return an array holds HWND elements.
See Win32::GUI::DIBitmap for more details.
Lilo Huang
Copyright 2014 by Lilo Huang All Rights Reserved.
You can use this module under the same terms as Perl itself.
Win32::Capture - Capture screen and manipulate it with Win32::GUI::DIBitmap instance. |