Perl Imager::Screenshot not doing screenshot with default parameters -
i have following code:
use imager::screenshot 'screenshot'; $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 prints:
"can't call method "write" on undefined value @ line 3"
but when do:
use imager::screenshot 'screenshot'; $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 take screenshot. why left, right, top , bottom values matter here?
edit: after research found out left param must smaller right param , top must smaller bottom.
have tried checking error? e.g.
my $img = screenshot(...) or die imager->errstr;
edit: try code:
use imager::screenshot 'screenshot'; $img = screenshot(hwnd => 'active', left => 450, right => 200, top => 50, bottom => 50 ) or die imager->errstr; $img->write(file => 'screenshot.png', type => 'png' ) || print "failed: ", $img->errstr, "\n";
Comments
Post a Comment