Reputation: 7623
I am writing an application using C# and WPF. Is there some way that my app can be notified whenever GetActiveWindow changes, or am I stuck with making a thread and monitoring the changes myself?
Upvotes: 2
Views: 330
Reputation: 16162
use Activated event like:
//at window load or at the constructor
this.Activated += OnWindowActivated;
private void OnWindowActivated(object sender, EventArgs e)
{
//your code here
}
Edit: As you want it to be for any window in the OS. check this similar question.
Upvotes: 1