How to open two separate (default) browser windows instead of new tabs

I am trying to use C # to open two separate window browsers side by side. I tried using Process.Start(url) , but this forces Chrome to open new tabs instead of new windows. This is similar to IE, but I would like to have code that can work with various types of browsers, namely IE, Chrome, Firefox and Safari. How to determine the default browser and then open two separate windows side by side? In addition, I want to be able to place two windows next to each other, is this possible?

+4
source share
2 answers

This is more about setting up the browser than about how the process is called from C #. In both cases, the system simply calls the default program assigned to handle the URL. There may or may not be arguments for this command, but usually it just calls chrome.exe <url> , and from there the chrome.exe process decides how to handle the parameter.

The only method I know about is to check the registry (in the HKEY_CLASSES_ROOT\http\shell\open\command section) and parse the string value. Once you know the specific browser, you can control the presentation using command line arguments. Of course, this is specific to Windows and can be a pain to manage.

If the browser does not support setting geometry from the command line, you will need to use FindWindow and SetWindowPos (using P / Invoke) to control the location of the window.

I'm not sure about your application, but would I embed WebBrowser Control according to your needs? Then you will have full control over the presentation.

+1
source

If you want to open a new window in chrome instead of a new tab, this code worked for me

  Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = "chrome"; process.StartInfo.Arguments = <yoururl> + " --new-window"; process.Start(); 
+2
source

Source: https://habr.com/ru/post/1443130/


All Articles