BTW, I tested the proposed code and it does NOT work unless the underlying page takes more than Timeout to load and still generates events. If you test it you MUST NOT move the mouse about the IE window as that generates events that would not otherwise occur and can thus distort the results.
#!/usr/bin/perl -w use 5.006; use strict; use warnings; use Win32::OLE qw(EVENTS); use Time::HiRes qw(gettimeofday); Win32::OLE->Option(_Unique => 1); sub IENavigate( $ ); $| = 1; # do not buffer output my $IE; my $IETimeout = 60; my $timeAtStart; #new global var my @urls = qw( http://www.google.com http://www.cnn.com/ ); # start ie, connect to events, make IE visible, connect alarm handler $IE = Win32::OLE->new("InternetExplorer.Application") || die "Could not start Internet Explorer.Application\n"; Win32::OLE->WithEvents($IE,\&IEEvent,"DWebBrowserEvents2"); $IE->{visible} = 1; $SIG{ALRM} = \&IEAlarm; # visit some URLs foreach (@urls){ print "Navigate to $_\n"; my $seconds = IENavigate( $_ ); print "took $seconds\n"; } # we're done print "Done\n"; # kill this IE $IE->Quit(); exit; # ################################################################### # sub IENavigate( $ ) { my $url = shift; my $seconds = 0; print "IENavigate $url\n"; $timeAtStart = time unless ($timeAtStart); alarm $IETimeout; $IE->navigate($url); Win32::OLE->MessageLoop(); print "Finished Blocking\n"; return; } sub IEEvent(){ my ($Obj,$Event,@Args) = @_; if (($IETimeout) && ($timeAtStart) && (time > ($timeAtStart + $IET +imeout) )) {&IEAlarm(17)}; print "IEEvent '$Event'\n"; } sub IEAlarm(){ my $sig = shift; print "IEAlarm $sig\n"; Win32::OLE->QuitMessageLoop(); }

In reply to Re^3: Win32::OLE and timeout by puff
in thread Win32::OLE and timeout by puff

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.