Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: screenshot module on Windows

by BrowserUk (Patriarch)
on Feb 10, 2010 at 19:22 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-26 03:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found