I'm trying to make a browser open as a pop under by using C#. Basically, I'm detecting when a browser is started by the user and I want to immediately after that open a new browser window which is under the window that the user opened. Here is what I have so far:
url = "example.com";
Process[] pname = Process.GetProcessesByName("chrome");
if (pname.Length == 0) // if the user didn't start chrome
{
chrome = false;
}
else // if chrome is running
{
if (!chrome) // if the browser wasn't opened before and it was opened just now.
{
Process process = new Process();
process.StartInfo.FileName = "chrome";
process.StartInfo.Arguments = url;
process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
process.Start();
//Process.Start("chrome", url);
}
chrome = true;
}
But what this does is sometimes open it in a new window and sometimes in a new tab. Perhaps I should use a different way of starting a browser or something? Thanks!