2011-09-01 82 views
1

我正在处理一个项目,其中我希望在Internet Explorer获得焦点时或在浏览标签时通知我的程序。为了让IE的实例获得焦点或用户选择另一个选项卡时更清晰,我希望我的程序得到通知。如何在Internet Explorer获得焦点时得到通知

我只是试图用AutomationFocusChangedEventHandler来做到这一点,正如我在前面的问题中提到的:AutomationFocusChangedEventHandler does not always fire。但它似乎没有适合与标签交互。

(看来我以前的问题是非常具体的,所以我试图使它更通用)

所以我想知道是否有一种方式,我的应用程序可以被通知当Internet Explorer获取焦点或用户在IE的同一实例中选择不同的选项卡?

或者,如果它仍然非常具体,有什么办法可以在焦点改变时通知我的程序?

+0

你的应用程序是一个独立的进程,而不是浏览器插件,对吗? –

+0

是的,没错。 – Luke

回答

0

Here是一个类似的应用程序。看看它是否有帮助。

//This Function is used to get Handle for Active Window... 
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)] 
private static extern IntPtr GetForegroundWindow(); 

public static IntPtr getforegroundWindow() 
{ 
    //This method is used to get Handle for Active Window using GetForegroundWindow() method present in 
    user32.dll 
    return GetForegroundWindow(); 
}