【问题标题】:Check for already open browser and URL检查已打开的浏览器和 URL
【发布时间】:2015-07-21 00:48:20
【问题描述】:

有没有办法在 VB.NET 中检查已经打开的带有特定 URL 的浏览器窗口,以便 Process.Start 不会打开新的浏览器窗口?例如,如果我已经打开了 Pinterest,我想将我的新搜索从我的 TextBox 发送到已经打开的窗口。

我每次打开新窗口的代码:

System.Diagnostics.Process.Start("iexplore.exe", "https://www.pinterest.com/search/pins/?q=" & Net.WebUtility.UrlEncode(TextBox1.Text))

【问题讨论】:

    标签: vb.net url textbox


    【解决方案1】:

    这个 sn-p 应该为你做。

    它将在 Windows Explorer 的窗口中浏览包含您的搜索查询 (Squery) 的 Internet Explorer 实例,并要求用户输入搜索查询。

    使用的参考位于 (%Windir%\System32\shdocvw.dll)

    Sub Main()
            Dim shellWins As SHDocVw.ShellWindows
            Dim explorer As SHDocVw.InternetExplorer
    
            shellWins = New SHDocVw.ShellWindows
            Dim SQuery As String = "https://www.pinterest.com/search/pins/?q="
            For Each explorer In shellWins
                If explorer.Application.Name = "Internet Explorer" And explorer.LocationURL.Contains(SQuery) Then
                    explorer.Navigate(SQuery & InputBox("Pinterest", "", Nothing, Nothing))
                End If
            Next
    
            shellWins = Nothing
            explorer = Nothing
        End Sub
    

    【讨论】:

      最近更新 更多