【问题标题】:Navigate all opened IE in shellwindows在 shellwindows 中导航所有打开的 IE
【发布时间】:2015-01-09 11:05:31
【问题描述】:

我在加载事件中打开了 2 个 Ie

    Dim Start As New ProcessStartInfo
    Dim Windows As New ShellWindows ' ShellWindowsClass
    Dim Count = Windows.Count
    Start.FileName = "iexplore.exe"
    Start.Arguments = "-private -nomerge  " & "https://www.yahoo.com"
    If WindowState = ProcessWindowStyle.Hidden Then
        Start.WindowStyle = ProcessWindowStyle.Minimized
    Else
        Start.WindowStyle = WindowState
    End If
    Dim nos As Integer

    nos = 2

    For i = 1 To nos
        Process.Start(Start)
    Next
    Application.DoEvents()
    Threading.Thread.Sleep(1000)
    For Each ie In New ShellWindows

        If ie.LocationURL.Length < 1 Or InStr(ie.LocationURL, "yahoo.com") > 1 Then 
            ie.ToolBar = False
            ie.StatusBar = True
           ie.AddressBar = False
            ie.MenuBar = False
        End If
        Application.DoEvents()
    Next

这段代码很好,可以打开 2 个 Ie 窗口 接下来如何将两个窗口导航到 google.com

我正在尝试这些代码 Dim ie As InternetExplorer 对于每个 ie 在新的 ShellWindows 中 如果 InStr(ie.LocationURL, "yahoo.com") > 1 那么 ie.Navigate("http://www.google.com) 结束如果

我收到了这个错误

请求的资源正在使用中。 (HRESULT 异常:0x800700AA) 下一个

【问题讨论】:

    标签: vb.net visual-studio-2010 internet-explorer-9


    【解决方案1】:

    ShellWindows 本身就是一个集合,因此您无需在通过 for 循环重复时创建集合的新实例。

    您的 Windows 对象变量将保存属于 shell 的打开窗口的集合

    将您的代码改为:

    For Each ie In Windows
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-18
      • 2021-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多