我正在尝试使用 C# 使浏览器作为弹出窗口打开。基本上,我正在检测用户何时启动浏览器,并且我想在此之后立即打开一个新的浏览器窗口,该窗口位于用户打开的窗口下方。这是我到目前为止所拥有的:
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;
}
但这有时会在新窗口中打开它,有时在新选项卡中打开。也许我应该使用不同的方式来启动浏览器之类的?谢谢!