in reply to Re: Using Win32::GUI::DIBitmap for screen capture
in thread Using Win32::GUI::DIBitmap for screen capture

I've done some more testing. But just like ChrisR could not get it working yet. I could grab the entire screen to an image but not the desired window only.

On a moment I moved from Win32::Gui::DIBitmap and tried using Win32::Screenshot to grab a window shot instead of the entire screen. The following code works with grabbing the window. The only problem it gave me was windows sometimes not being quick enough to build up the screen. This resulted in other windows being in the shot.

It is probably not what you are looking for, but I wanted to share the code snippet anyways

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'); }
Cheers,
Critter