use Win32::Screenshot; use Win32::GuiTest qw(FindWindowLike SetForegroundWindow); my @windows = FindWindowLike(0,qr/^search.cpan.org/); if (defined($windows[0])) { SetForegroundWindow($windows[0]); my $image = CaptureWindow($windows[0]); $image->Write('screenshot.png'); }