检查已经打开的浏览器和 URL
Check for already open browser and URL
有没有办法检查 VB.NET 中特定 URL 的已打开浏览器 windows,以便 Process.Start
不会打开新浏览器 windows?例如,如果我已经打开了 Pinterest,我想将我的新搜索从我的文本框发送到已经打开的 window。
我的代码每次打开新的window:
System.Diagnostics.Process.Start("iexplore.exe", "https://www.pinterest.com/search/pins/?q=" & Net.WebUtility.UrlEncode(TextBox1.Text))
这段代码应该可以为您完成。
它将浏览 windows 资源管理器的 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
有没有办法检查 VB.NET 中特定 URL 的已打开浏览器 windows,以便 Process.Start
不会打开新浏览器 windows?例如,如果我已经打开了 Pinterest,我想将我的新搜索从我的文本框发送到已经打开的 window。
我的代码每次打开新的window:
System.Diagnostics.Process.Start("iexplore.exe", "https://www.pinterest.com/search/pins/?q=" & Net.WebUtility.UrlEncode(TextBox1.Text))
这段代码应该可以为您完成。
它将浏览 windows 资源管理器的 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