2015-07-21 76 views
1

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

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

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

回答

0

该段应为你做它。

它将通过Windows资源管理器的窗口浏览包含您的搜索查询(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 

enter image description here

发现