Hello,

Would it really be a bad idea using the GetInputState function of user32 ?

It :
determines whether there are mouse-button or keyboard messages in the calling thread's message queue.
It needs then a timer and a static variable (to retrieve the time T1 each time there is an activity). You decide to close if The Time T2 - Time T1 >= accepted delay.

You would that way save to attach code to every control ...