Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found