DACONTI has asked for the wisdom of the Perl Monks concerning the following question:

Dear Perlmonks,
I'm trying to use Win32::IEAutomation to automatize some secure tasks.
Altough I can easily connect to the site and login, I cannot spot out how to go further because I loose myself into javascript and frame problems.
Now I was thinking, perhaps there is a way to bring Win32::IEAutomation to connect to an existing IE session (I know that this can be done for Excel instances for example).
In this way I could move to the desired page by hand but then navigate further and fill forms automatically through Win32::IEAutomation

Thanks for any advice.
Davide.
  • Comment on Win32::IEAutomation and existing IE session

Replies are listed 'Best First'.
Re: Win32::IEAutomation and existing IE session
by Anonymous Monk on Feb 06, 2009 at 16:57 UTC
    Now I was thinking, perhaps there is a way to bring Win32::IEAutomation to connect to an existing IE session (I know that this can be done for Excel instances for example).
    Try
    package IeExisting; use Win32::IEAutomation; @IeExisting::ISA='Win32::IEAutomation'; sub _startIE{ my ($self, $visible, $maximize) = @_; defined $self->{agent} and return; $self->{agent} = Win32::OLE->GetActiveObject('InternetExplorer.Application') || Win32::OLE->new("InternetExplorer.Application") || die "Could not start Internet Explorer Application through OLE\n"; Win32::OLE->Option(Warn => 0); Win32::OLE->WithEvents($self->{agent}); $self->{agent}->{Visible} = $visible; if ($maximize){ my $clicker = Win32::IEAutomation::WinClicker->new(); $clicker->maximize_ie(); undef $clicker; } return $self; } ...
      Many thanks,
      it was exactly what I was looking for and it works fine!
      Best Regards,
      Davide.
        Hi PMs,

        I too am trying to reuse an IE session but have no success with this:

        use IeExisting; my $ie = IeExisting->new( visible => 1, maximize => 1, warnings => 1); $ie->gotoURL('http://www.google.com');

        This starts up a new IE window rather than finding/connecting to existing session.

        I confirmed it is using the IeExisting constructor (by commenting out the line with "->new" from IeExisting, but then I get an error "Could not start Internet Explorer Application through OLE" when trying to connect to an existing session

        Or am I doing something wrong?

        Suggestions and comments welcome.

        I'm using IE7 on XP.

        Thanks...