As is, this captures a bitmap of the whole screen. Use "%{PrtScn}" for just the current window. Interpreting and manipulating the bitmap captured is over to you. You may find this document useful. The site's pretty damn useful too. Qudos to PodMaster for a reference to that some time back.

#! perl -slw #use Win32::Bitmap; use strict; use Win32::GuiTest qw[SendKeys]; use Win32::Clipboard; my $cb = Win32::Clipboard->new(); $cb->Empty(); SendKeys( "+{PRTSCR}" ); $cb->WaitForChange(); my $image = $cb->GetBitmap() or die 'No bitmap there'; print 'Total size:', length $image; my %BMPinfo; @BMPinfo{ ( '01UINT type', #! 2 '02DWORD size', #! 4 '03UINT Reserved1', #! 2 '04UINT Reserved2', #! 2 '05DWORD Offset', #! 4 '06DWORD biSize', #! 4 '07LONG biWidth', #! 4 '08LONG biHeight', #! 4 '09WORD biPlanes', #! 2 '10WORD biBitCount', #! 2 '11DWORD biCompression', #! 4 '12DWORD biSizeImage', #! 4 '13LONG biXPelsPerMeter', #! 4 '14LONG biYPelsPerMeter', #! 4 '15DWORD biClrUsed', #! 4 '16DWORD biClrImportant', #! 4 ) #!54 } = unpack 'A2 L S S L L V V s s L L V V L L', substr $image, 0, 54; printf '%23s : %s'.$/, $_, $BMPinfo{$_} for sort keys %BMPinfo; __END__ C:\test>231894 Total size:1572918 01UINT type : BM 02DWORD size : 1572918 03UINT Reserved1 : 0 04UINT Reserved2 : 0 05DWORD Offset : 54 06DWORD biSize : 40 07LONG biWidth : 1024 08LONG biHeight : 768 09WORD biPlanes : 1 10WORD biBitCount : 16 11DWORD biCompression : 3 12DWORD biSizeImage : 1572864 13LONG biXPelsPerMeter : 0 14LONG biYPelsPerMeter : 0 15DWORD biClrUsed : 0 16DWORD biClrImportant : 0

Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.


In reply to Re: capture what's on the screen by BrowserUk
in thread capture what's on the screen by pg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.