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

Hello, Think I found something for you that seems to be working. I did not test it further but I do get a value back now. Hope this helps.
use Win32::GUI; use Win32::GUI::DIBitmap; use Win32::GuiTest qw(FindWindowLike GetWindowText); my @windows = FindWindowLike(0, qr/^search.cpan.org/); my $hdc = Win32::GUI::DC->new($windows[0]->{handle}); print "hcd is $hdc\n"; print "Window name is '" . GetWindowText($windows[0]) . "'\n"; my $bmap = newFromDC Win32::GUI::DIBitmap ($hdc); print "bmap is $bmap\n";
This results in:
C:\code>perl dibitmap.pl hcd is 318833948 Window name is 'search.cpan.org: The CPAN Search Site - Microsoft Inte +rnet Explo rer' bmap is Win32::GUI::DIBitmap=SCALAR(0x2251a4)
Cheers,
Critter

Replies are listed 'Best First'.
Re^2: Using Win32::GUI::DIBitmap for screen capture
by ChrisR (Hermit) on Jul 29, 2005 at 19:39 UTC
    You are getting the DC for the desktop. $windows[0]->{handle} is null.
Re^2: Using Win32::GUI::DIBitmap for screen capture
by critter (Acolyte) on Jul 31, 2005 at 19:53 UTC
    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