我想通过使用C#使浏览器打开为弹出窗口。基本上,我正在检测用户何时启动浏览器,然后我想立即打开用户打开的窗口下的新浏览器窗口。以下是我迄今为止:在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;
}
但是,这并在一个新的窗口,有时在一个新的标签,有时打开它。也许我应该使用不同的方式来启动浏览器或其他东西?谢谢!
谢谢你!它的作品:) – armin
@ArminAšimović不客气。 – varocarbas