You could also use a timer control, and monitor (say every 30 secs) the name of the currently selected control.
If this control has changed, then your counter resets, but if your counter reaches 300, then it means your app has not been used for 5 minutes.
This has another advantage in that the...