运行对象表未从脚本注册IE实例 [英] Running Object Table not registering IE instance from script

查看:146
本文介绍了运行对象表未从脚本注册IE实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我为什么如果我手动打开IE的实例,运行对象表(ROT)已注册了所有实例,但是如果我使用vb脚本打开IE的实例,则只有第一个实例在ROT上注册了

有什么办法可以解决这个问题??

谢谢


示例:是一个控制台应用程序,它对IE的实例进行计数并打开它们的名称3生成了IE实例,但count = 1但count应该= 3

如果我手动打开IE,那么所有手动打开的实例都会被计数.

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.

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 

推荐答案

那里有一篇有趣的CodeProject文章来捕获正在运行的IE实例.参考:捕获C#中正在运行的IE实例 [
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.


如果您正在谈论代码中的这三个CreateObject行,则计数应为1,而不是3.您不会启动IE进程的3个单独实例.您正在创建一个COM服务器的实例,该实例只会显示一次以分配您的实例.
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.


好吧,戴夫

您能告诉我如何编写脚本,使其成为一个实例,还是我需要捕获的代码,比如说yahoo页面的ie窗口标题
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


这篇关于运行对象表未从脚本注册IE实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆