Click here to Skip to main content
15,861,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone tell me why if I manually open instances of IE the Running Object Table (ROT) has registers all instances but if I use vb scripting to open instances of IE only the first instance is registered on the ROT

Is there any way to fix this????

Thks


The example: is a console app it count the instances of IE and their names opens 3 IE instance are generated but count = 1 but count should = 3

If I manually open IE then all manual opened instances are counted.

VB
Imports System.Threading.Thread
Imports System.Text.RegularExpressions
Imports SHDocVw
Imports mshtml

Module Module1
Dim objIE As InternetExplorer = Nothing
Dim objIE11 As InternetExplorer = Nothing
Dim objIE21 As InternetExplorer = Nothing
Sub Main()


objIE = CreateObject("InternetExplorer.Application")

objIE.Navigate("http://www.google.com.au")
objIE.Visible = True

While objIE.Busy = True
Sleep(1000)
End While

Dim blnFoundSubmit As Boolean = False
Do
Dim a
For Each a In objIE.Document.GetElementsByTagName("A")
If a.innerText = "News" Then
blnFoundSubmit = True
Exit For
End If
Next
If blnFoundSubmit Then
a.Click() ' NOTE: allow pop-ups...
Sleep(2000)
Else
Sleep(200)
End If
Loop Until blnFoundSubmit

objIE11 = CreateObject("InternetExplorer.Application")

objIE11.Navigate("http://ninemsn.com.au/")
objIE11.Visible = True

While objIE11.Busy = True
Sleep(1000)
End While

objIE21 = CreateObject("InternetExplorer.Application")

objIE21.Navigate("http://au.yahoo.com/")
objIE21.Visible = True

While objIE21.Busy = True
Sleep(1000)
End While

Do
ScanIEWindows()

Threading.Thread.Sleep(2000)

ScanIEWindows()

Threading.Thread.Sleep(2000)
Loop
Console.ReadLine()
End Sub

Public Sub ScanIEWindows()
Dim windows As New SHDocVw.ShellWindows()

Console.WriteLine(windows.Count)

For Each window As SHDocVw.InternetExplorer In windows
Console.WriteLine(window.LocationName)
Console.WriteLine(window.LocationURL)
Next
End Sub

End Module 
Posted

Therez an interesting CodeProject article to capture running IE instances. Ref: Capturing the Running IE Instances in C#[^]

Apparently, those instances can be registered later.
 
Share this answer
 
If you're talking about those three CreateObject lines in your code, the count should be 1, not 3. You're not launching 3 seperate instances of an IE process. You're creating instances of a COM server which will only show up once to dole out your instances.
 
Share this answer
 
ok thks dave

Can you tell me how to script so it is an instance or what code I would need to capture lets say the ie window title of the yahoo page
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900