Hello Monks,

Hopefully this will be relatively straight forward, but I'm tearing my hair out at the moment. I am trying to automate a simple lookup to a web page for a game that I'm on. I need to increase my hits to one of my status pages. I have found out that a 'hit' seems to be related to the browser session, and that the best thing to do is to hit the web page, close explorer and wait 30 minutes before trying again. So, I've googled, and found out how to control IE via OLE and use the Events triggered to catch where the DocumentComplete and OnQuit events are triggered. As below

use strict; use Win32::OLE qw(EVENTS); my $URL = "http://REQUIRED WEB PAGE"; my $IE; my $timeout; displaywebpage(); sub Event { my ($Obj,$Event,@Args) = @_; my $IEObject; print "Here is the Event: $Event\n"; if ($Event eq "DocumentComplete") { $IEObject = shift @Args; print "URL: " . $IEObject->Document->URL . "\n"; print "Now quit IE\n"; $IE->Quit; } elsif ($Event eq "OnQuit") { Win32::OLE->QuitMessageLoop(); } } sub displaywebpage { $IE = Win32::OLE->new("InternetExplorer.Application") || die "Could not start Internet Explorer.Application\n"; $IE->{visible} = 1; Win32::OLE->WithEvents( $IE, \&Event, 'DWebBrowserEvents2' ); $IE->Navigate($URL); Win32::OLE->MessageLoop(); $timeout = 30*60; # n seconds print "Wait for $timeout seconds\n"; $timeout -= sleep $timeout while $timeout > 0; print "Now start again\n"; displaywebpage(); }

The problem is that the OnQuit event fires before IE quits and even with the OnQuit event handler only terminating the message loop, so that it goes back to the perl script to fire another IE after the timeout, the IE window only really quits at the point that the new window is opened.

I want the IE window to quit, then wait for 30 minutes before opening a new window to do the same thing.

Any wisdom you can supply would be most welcome

Thanks


In reply to Controlling IE and making it QUIT !! by BrianP6

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.