]>
Commit | Line | Data |
---|---|---|
0ddb7051 TC |
1 | #!perl -w |
2 | use strict; | |
3 | use Win32::API; | |
4 | use Imager; | |
5 | use Imager::Screenshot 'screenshot'; | |
6 | ||
7 | # delay so I can bring the window to the front | |
8 | sleep 2; | |
9 | ||
10 | # get the API | |
11 | my $find_window = Win32::API->new('user32', 'FindWindowA', 'NP', 'N') | |
12 | or die "Cannot import FindWindow\n"; | |
13 | ||
14 | # get the window, this requires an exact match on the window title | |
15 | my $hwnd = $find_window->Call(0, "use Perl: All the Perl that's Practical to Extract and Report - Mozilla Firefox"); | |
16 | ||
17 | $hwnd | |
18 | or die "Mozilla window not found"; | |
19 | ||
20 | # take a picture, including the border and title bar | |
21 | my $img = screenshot(hwnd => $hwnd, decor=>1) | |
22 | or die Imager->errstr; | |
23 | ||
24 | # and save it | |
25 | $img->write(file=>'mozilla.ppm') | |
26 | or die $img->errstr; | |
27 |