/ home / projects / blog / 2005 / 04 / usrbinperl-use-win32-ole-qwevents-my.php :: . : .. |
|
#!/usr/bin/perl use Win32::OLE qw(EVENTS); my $URL = "http://www.jwalsh.net/projects/blog/"; my $IE = Win32::OLE->new("InternetExplorer.Application") || die "Could not start Internet Explorer.Application\n"; Win32::OLE->WithEvents($IE,\&Event,"DWebBrowserEvents2"); $IE->{visible} = 1; $IE->Navigate2($URL); Win32::OLE->MessageLoop(); sub Event { my ($Obj,$Event,@Args) = @_; print "Here is the Event: $Event @Args\n"; if ($Event eq "DocumentComplete") { $IEObject = shift @Args; print "URL: " . $IEObject->Document->URL . "\n"; print "Title: " . $IEObject->Document->Title . "\n\n"; # Win32::OLE->QuitMessageLoop(); } if ($Event eq "onQuit") { Win32::OLE->QuitMessageLoop(); } }
posted by j 4/26/2005 06:41:00 AM