Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: How to capture screen under Win32?

by lshatzer (Friar)
on Apr 10, 2002 at 17:04 UTC ( [id://158074]=note: print w/replies, xml ) Need Help??


in reply to How to capture screen under Win32?

I was unable to do this, but this might get you in the right area, I assume this is for Windows, if not, sorry.

Try the Win32::API module, and I belive the Win32 API call is GetDC() in user32.dll. The quick test script I ran segfaulted perl, so I doubt this will work, but I just put 5 minutes into looking, and trying it out, this will at least point you in the right direction.

Just so you see my test script (which might be wrong with the Win32 API call, since I've never used this module):
use Win32::API; my $screenshot = new Win32::API("user32", "GetDC", '', 'N'); my $shot = $screenshot->Call();
Update It appears there is also another GetDC in Windows land that is dealing with Getting the Domain Controler, unlike this one, which is Device Control, or something like that. Hope this helps.

Replies are listed 'Best First'.
Re: Re: How to capture screen under Win32?
by RMGir (Prior) on Apr 10, 2002 at 18:39 UTC
    I could be wrong, and probably am :), but I think GetDC is much likelier to be in GDI32 (the graphics engine) than user32.

    I think your $screenshot handle is probably undefined.
    --
    Mike

      Using a quickview program, in USER32.dll, it has GetDC()listed. In GDI32.dll it had stuff like GetDCBrushColor and some other various ones like that. Output from $screenshot handle from original code (before the $screenshot->Call() via Data::Dumper:
      $VAR1 = bless( { 'dllname' => 'user32', 'dll' => 2011234304, 'proc' => 2011246207, 'out' => 1, 'in' => [] }, 'Win32::API' );
        Cool...

        I told you I was probably wrong :)

        I just checked the MS docs, and getDC takes a window handle as an argument. Pass 0 to get the DC for the whole screen.

        And don't forget to call ReleaseDC, or bad things can happen...

        We now exit MS win32 api hell, and return you to your regularly scheduled perl programming :)
        --
        Mike

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://158074]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-23 07:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found