2015-07-21 71 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

發現