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?
精彩评论