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

Re: screenshot module on Windows

by BrowserUk (Pope)
on Feb 10, 2010 at 19:22 UTC ( #822495=note: print w/replies, xml ) Need Help??

in reply to screenshot module on Windows

If you have a command line bmp to png converter (or jpg etc. like this one), then you can do this quite easily without any of the complex installs:

#! perl -slw use strict; use Win32::GuiTest qw[FindWindowLike SetForegroundWindow SendKeys]; use Win32::Clipboard; my $clip = Win32::Clipboard->new(); my @windows = FindWindowLike( 0, $ARGV[ 0 ] ); #Find it die "Couldn't find window '$ARGV[ 0 ]" unless @windows; for (@windows) { SetForegroundWindow( $_ ); # Make it active sleep 1; ## Send the Alt-print screen key sequence to copy ## the active window to the clipboard SendKeys("%{PRTSCR}"); } my $fname = "$ARGV[ 0 ]-@{[ time() ]}"; print $fname; if( my $bitmap = $clip->GetBitmap() ) { local $\; my $bmpfile = $fname . '.bmp'; open my $bmp, '>', $bmpfile or die $!; binmode $bmp; print $bmp $bitmap; close $bmp; print "Bitmap written to $bmpfile\n"; system "bmp2png $bmpfile"; print "Converted to $fname.png"; } else { die "Couldn't get bitmap from clipboard"; } __END__ C:\test>screengrab Opera Opera-1265829469 Bitmap written to Opera-1265829469.bmp OK Opera-12658294 ooooooooooooooooooooooooooooooooooooooooooooooo +ooooo Converted to Opera-1265829469.png

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://822495]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2017-02-20 12:43 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (295 votes). Check out past polls.