开发者

AutomationFocusChangedEventHandler does not always fire

I'm working on a project in which I want my program to be notified when Internet Explorer gets focus or when navigating through tabs. To be clearer when an instance of IE gets focus or the user selects another tab, I want my program to be notified.

To do this, I used AutomationFocusChangedEventHandler like this:

AutomationFocusChangedEventHandler focusHandler;

private void StartListening()
{
    focusHandler = new AutomationFocusChangedEventHandler(OnFocusChanged);
    Automation.AddAutomationFocusChangedEventHandler(focusHandler);
}

private void OnFocusChanged(object src, AutomationFocusChangedEventArgs e)
{
    AutomationElement ae = AutomationElement.FocusedElement;
    if (ae.Current.ClassName == "Internet Explorer_Server")
    {
        //do something here
    }
}

It works fine when I click on different instances of IEs, but when interacting with tabs, with some of these tabs, the onFocusChanged does not fi开发者_如何学JAVAre. With some tabs, It works fine but for others it does not (It does not detect tab changing for some tabs). Why? Am I missing something?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜