powershell com internetexplorer catch popup window

502 Views Asked by At

I'm trying to use powershell to automate and parse a website. Everything works great until I "click" on a link and it opens in a new window. How can I access that window so I can parse it?

$ie = New-Object -com Internetexplorer.application 
$ie.Visible= $true
$ie.Navigate("http:/.....")
....
# find a link... 
$link.click(); # a new popup window open up.
# how can I get access to the new popup window?

Thank you!

1

There are 1 best solutions below

1
briantist On

Try using the NewWindow3 event so that you can grab the object when it gets created.

Raised when a new window is to be created. Extends NewWindow2 with additional information about the new window.
Syntax
        Private Sub object_NewWindow3( _
    ByRef ppDisp As Object, _
    ByRef Cancel As Boolean, _
    ByVal dwFlags As Long, _
    ByVal bstrUrlContext As String, _
    ByVal bstrUrl As String)