Take screenshots of websites (Internet Explorer)

A perl snippet I just found in my archive. Running with (Active)Perl under Windows, it enables you to take website screenshots. This is achieved by starting Internet Explorer, simulating a "print screen" press and printing the output to a bitmap file.

I cannot verify the integrity of the script but it should work just fine.

 

#!C:/Perl/bin/Perl -w

use Win32::OLE;
use Win32::API;
use Win32::Clipboard;
use Win32::InternetExplorer::Window;

my $key = new Win32::API("user32", "keybd_event", 'IINP', 'V');
#create new virtual keyboard keycode hook
die "Can't import user32.dll: $!\n" if(not defined $key);
#die if unable to reach user32.dll

my $clip = Win32::Clipboard();
#create new clipboard object

my $browser = Win32::OLE->new('InternetExplorer.Application') or die "Failed to start \n"; 
#load internet explorer

$browser->Navigate('http://turbo10.com',1,'_BLANK');
#browse to website specified
sleep(4); #wait 4 seconds...dirty hack
#$browser->{'Visible'} = 1;
#disabled because we assume a non-busy system with only IE being active

# empty the clipboard
$clip->Empty();

# press the key!!
$key->Call(0x2C, 0x45, 0x01, 0);
#simulate a "printscrn" key press
$key->Call(0x2C, 0x45, 0x03, 0);
# & release

# wait for the image to fill the clipboard
$clip->WaitForChange();

#get the actual image from clipboard
my $image = $clip->GetBitmap();

open (BITMAP, ">test.bmp");
binmode BITMAP;
#enable binary mode for incoming image
print BITMAP $image;
#print image to bitmap file
close(BITMAP);


#  my $browser = Win32::InternetExplorer::Window->new(height => 600,
#                                                   width => 600,
#                                                  pos => [10,0],
#                                                   #no_popups => 1,
#                                                   #start_hidden => 1
#                                                   );
#  $browser->display('http://www.aol.com');
#  sleep(2);
#  $browser->refresh_wait();
#  sleep(2);
#  system('import -window root image.jpg');
#  $browser->stop();

Source: (2006-08-08 01:30:57)