Help!!

I'm writing an application that minimizes to the background - and stays
minimized unless a number of seconds go by (user defined) of inactivity
by the mouse and keyboard. I need a way of capturing keyboard activity
and mouse activity within the timer event of the minimized application
to detect when to trigger a time out message to the user. I was
thinking of using an API to accomplish this, but wasn't sure which one
would be appropriate.

Please let me know!!

Thanks!