Win32::CaptureIE - Capture web pages or its elements rendered by Internet Explorer
use Win32::CaptureIE; StartIE; Navigate('http://my.server/page.html'); my $img = CaptureElement('tab_user_options'); $img->Write("ie-elem.png"); QuitIE;
The package enables you to automatically create screenshots of your web server pages for the user guide or whatever you need it for. The best part is that you don't bother yourself with scrolling and object localization. Just tell the ID of the element and receive an Image::Magick object. The package will do all the scrolling work, it will take the screenshots and glue the parts together.
CaptureBrowser CaptureElement CapturePage GetDoc GetElement Navigate QuitIE Refresh StartIE $Body $CaptureBorder $Doc $HWND_Browser $HWND_IE $IE
CaptureBrowser
CaptureElement
CapturePage
GetDoc
GetElement
Navigate
QuitIE
Refresh
StartIE
$Body
$CaptureBorder
$Doc
$HWND_Browser
$HWND_IE
$IE
This function creates a new Internet Explorer process via Win32::OLE. You can specify width and height of the window as parameters.
StartIE( width => 808, height => 600 );
The function will bring the window to the top and try to locate the child window where the page is rendered.
Terminates the Internet Explorer process and destroys the Win32::OLE object.
Loads the specified page and waits until the page is completely loaded. Then it will call GetDoc function.
Refreshes the currently loaded page and calls GetDoc function.
Loads $Doc and $Body global variables.
Returns the object of specified ID by calling document->getElementById().
document->getElementById()
These function works like other Capture*(...) functions from Win32::Screenshot package.
Capture*(...)
Captures whole Internet Explorer window including the window title and border.
Captures whole page currently loaded in the Internet Explorer window. Only the page content will be captured - no window, no scrollbars. If the page is smaller than the window only the occupied part of the window will be captured. If the page is longer (scrollbars are active) the function will capture the whole page step by step by scrolling the window content (in all directions) and will return an complete image of the page.
Captures the element specified by its ID or passed as reference to the element object. It will capture a small border around the element specified by $CaptureBorder global variable. The function will scroll the page content to show the top of the element and scroll down and right step by step to get whole area occupied by the object.
The function CaptureElement is able to capture the element and a small area around it. How much of surrounding space will be captured is defined by $CaptureBorder. It is not recommended to capture more than 3-5 pixels because parts of other elements could be captured as well. Default border is 1 pixel wide.
The function StartIE will create a new Internet Explorer process and its Win32::OLE reference will be stored in this variable. See the MSDN documentation for InternetExplorer object.
The function GetDoc will assign $IE->{Document} into this variable. See the MSDN documentation for Document object.
$IE->{Document}
The function GetDoc will assign $IE->{Document}->{Body} into this variable. See the MSDN documentation for BODY object.
$IE->{Document}->{Body}
The function StartIE will assign the handle of the Internet Explorer window into this variable from $IE->{HWND}.
$IE->{HWND}
The function StartIE will try to find the largest child window and suppose that this is the area where is the page rendered. It is used to convert page coordinates to screen coordinates.
Access denied
Sometimes I receive the error message 'Access denied' when accessing $Doc->{parentWindow} properties and methods (scrollBy and scrollTo methods are called from the package functions). Sometimes I have to close all running IE windows or restart computer if it's not enough to solve the problem. I will appreciate any help.
$Doc->{parentWindow}
scrollBy
scrollTo
http://msdn.microsoft.com/library You can find there the description of InternetExplorer object and DOM.
This package is used for capturing screenshots. Use its post-processing features for automatic screenshot modification.
P.Smejkal, <petr.smejkal@seznam.cz>
Copyright (C) 2004 by P.Smejkal
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.
2 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head1'
To install Win32::CaptureIE, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::CaptureIE
CPAN shell
perl -MCPAN -e shell install Win32::CaptureIE
For more information on module installation, please visit the detailed CPAN module installation guide.