問題描述
我想打開一個(gè)隱藏的 Internet Explorer 窗口,但它不會竊取焦點(diǎn).我有一個(gè) Timer 對象,它每 5 分鐘打開一次 Internet Explorer 以檢查網(wǎng)站是否有更新.問題是每次檢查更新時(shí),它都會從前臺的當(dāng)前應(yīng)用程序中竊取焦點(diǎn).下面是我如何開始這個(gè)過程:
I want to open a hidden Internet Explorer window without it stealing focus. I have a Timer object that opens Internet Explorer every 5 minutes to check a website for updates. The problem is every time it checks for updates, it steals focus from the current application in the foreground. Below is how I start the process:
Process m_Proc = new Process();
m_Proc.StartInfo.Arguments = String.Format("{0}{1}", "-nomerge ", browserURL);
m_Proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
m_Proc.StartInfo.UseShellExecute = true;
m_Proc.StartInfo.CreateNoWindow = true;
m_Proc.StartInfo.FileName = String.Format("iexplore.exe");
m_Proc.Start();
它總是偷走焦點(diǎn),即使它是隱藏的.我希望它像什么都沒有發(fā)生一樣開始,所以用戶可以繼續(xù)他們正在做的事情.謝謝.
It always steals focus, even when it is hidden. I want it to start like nothing is happening, so users can continue to work on what they are doing. Thanks.
推薦答案
嘗試通過其 COM 接口自動化 Internet Explorer,而不是顯式創(chuàng)建進(jìn)程.方法如下.只是不要這樣做 ie.Visible = true
它將保持隱藏狀態(tài).完成后調(diào)用 ie.Quit()
.
Try automating Internet Explorer via its COM interfaces rather than creating a process explicitly. Here's how it can be done. Just don't do ie.Visible = true
and it will stay hidden. Call ie.Quit()
when done with it.
這篇關(guān)于打開隱藏的 Internet Explorer 窗口而沒有獲得焦點(diǎn)?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!