in reply to Re: Win32::GuiTest - Processing screen captures in memory?
in thread Win32::GuiTest - Processing screen captures in memory?

I'm not sure what's wrong with that... the image does end up on the clipboard, but I can't get it back out into $image.

grabWindowRegion(0, 0,0,64,64); sub grabWindowRegion { my $ds = new Win32::GuiTest::DibSect; $ds->CopyClient(shift,[@_]); $ds->ToClipboard(); print Win32::Clipboard::IsBitmap() ? "Bitmap\n" : "Not Bitmap\n"; my $image = Win32::Clipboard::GetBitmap(); #Same results with just Get() print Dumper $image; die "\n"; # $ds->SaveAs('temp.bmp'); # return parseBMP('temp.bmp'); }
Gives:
Not Bitmap $VAR1 = '';

The image is definitely on the clipboard though, since if I open mspaint, I can Ctrl-V and get the "my computer" icon perl captured from my desktop...

Replies are listed 'Best First'.
Re^3: Win32::GuiTest - Processing screen captures in memory?
by BrowserUk (Patriarch) on Mar 20, 2011 at 00:18 UTC

    You are calling GetBitmap as a function. The documentation shows it being called as a class method. I suspect that is the cause of your problem as the following snippet successfully retrieves, saves and displays any image I place on the clipboard:

    #! perl -slw use strict; use Win32::Clipboard; my $cb = Win32::Clipboard->new(); my $bmp = $cb->GetBitmap; open O, '>:raw', 'junk.bmp' or die $!; print O $bmp; close O; system 'junk.bmp';

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      All the functions can be used either with their full name (eg. Win32::Clipboard::Get) or as methods of a Win32::Clipboard object.

      That said, I did try it as an object anyways, and got the same result again.

      If you call the IsBitmap() function, does it recognize the clipboard image on your system?

      I've also gone and updated everything available through PPM, and reinstalled guitest and clipboard to be sure I've got the latest. Running XP, in case that matters.

        If you call the IsBitmap() function, does it recognize the clipboard image on your system?

        Yes. I'm using AS1007 64-bit on Vista64. and version 0.55 of Win32::Clipboard:

        #! perl -slw use strict; use Win32::Clipboard; my $cb = Win32::Clipboard->new(); print $cb->IsBitmap() ? 'Yes' : 'No'; my $bmp = $cb->GetBitmap; open O, '>:raw', 'junk.bmp' or die $!; print O $bmp; close O; system 'junk.bmp'; __END__ c:\test>clipBMP.pl Yes c:\test>perl -MWin32::Clipboard -E"say $Win32::Clipboard::VERSION" 0.55

        I'm putting an image onto the clipbard using Alt-printscreen.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Win32::GuiTest - Processing screen captures in memory?
by Anonymous Monk on Mar 19, 2011 at 23:52 UTC
    IIRC, clipboard/bitmap is 24-bit type bitmap ... can your parseBMP deal with it?