Perl Imager::Screenshot not doing screenshot with default parameters

Posted by Grigor on Stack Overflow See other posts from Stack Overflow or by Grigor
Published on 2012-06-29T02:50:39Z Indexed on 2012/06/29 3:16 UTC
Read the original article Hit count: 433

Filed under:

I have the following code:

use Imager::Screenshot 'screenshot';
my $img = screenshot(hwnd => 'active', left => 450, right => 200, top => 50, bottom => 50);
$img->write(file => 'screenshot.png', type => 'png' ) || print "Failed: ", $img->{ERRSTR} , "\n";

it returns:

"Can't call method "write" on undefined value at line 3"

but when I do:

use Imager::Screenshot 'screenshot';
my $img = screenshot(hwnd => 'active', left => 100, right => 300, top => 100, bottom => 300);
$img->write(file => 'screenshot.png', type => 'png' ) || print "Failed: ", $img->{ERRSTR} , "\n";

it does take a screenshot. Why would the left, right, top and bottom values matter here?

© Stack Overflow or respective owner

Related posts about perl