I have a WPF application and I need to shell out to a browser application. I am using the Process.Start({url}) method to do this.
However, if the url is already displayed in the browser, I do not want to open another browser window or tab; I want to navigate to the browser/tab already open.
Is that at all possible?
You can enumerate the open IE windows using the following method:
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
string filename;
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("iexplore"))
{
try
{
Uri test = new Uri(ie.LocationURL);
}
catch
{
}
}
}
You'll need to add a reference to the SHDocVw COM component.
Also, if you're using a browser other than IE this won't work.
An alternative would be to use something like GeckoFX https://bitbucket.org/geckofx or a separate winform app with a WebBrowser control instead of using Process.Start
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.