打开隐藏的 Internet Explorer 窗口而没有获得焦点

Opening a Hidden Internet Explorer Window without it getting Focus?(打开隐藏的 Internet Explorer 窗口而没有获得焦点?)
本文介绍了打开隐藏的 Internet Explorer 窗口而没有获得焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开一个隐藏的 Internet Explorer 窗口,但它不会窃取焦点.我有一个 Timer 对象,它每 5 分钟打开一次 Internet Explorer 以检查网站是否有更新.问题是每次检查更新时,它都会从前台的当前应用程序中窃取焦点.下面是我如何开始这个过程:

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();

它总是偷走焦点,即使它是隐藏的.我希望它像什么都没有发生一样开始,所以用户可以继续他们正在做的事情.谢谢.

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,而不是显式创建进程.方法如下.只是不要这样做 ie.Visible = true 它将保持隐藏状态.完成后调用 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.

这篇关于打开隐藏的 Internet Explorer 窗口而没有获得焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)