Note: There\'s a very similar question, but it\'s WPF-specific; this one is not.
How can I determine if the current application is activ
You can subscribe to Main Window's Activated event