You do not need to change each control. If you add the following code at startup:
Application.Current.RootVisual.MouseMove += new MouseEventHandler(RootVisual_MouseMove); Application.Current.RootVisual.KeyDown += new KeyEventHandler(RootVisual_KeyDown);
With the following event handlers:
private void RootVisual_KeyDown(object sender, KeyEventArgs e) { idle = false; } private void RootVisual_MouseMove(object sender, MouseEventArgs e) { idle = false; }
Where idle is the variable that you use in your DispatcherTimer Tick event to check what is happening or not.
As events accumulate in the tree, this should work for all of your controls.
source share