Launch WinForms app when user inactive
I'm trying to create a WinForms app that will show a banner after x minutes and lock the screen. Now I currently do have a Form with an overlay that gradually fades the screen and will lock it. However I'm not sure how to launch it after x minutes of user inactivity.
Does Windows have any API's that you can listen to to make it easier? If anyone can guide me in the right direction that would be great.
8 Replies
you can poll for whenever there is mouse movement \ keyboard activity and store the time that it happens
then compare that timestamp against datetime.now
if the difference > 5 minutes (or whatever), show your banner
@Nemesis https://superuser.com/questions/777488/task-scheduler-what-is-wait-for-idle-for use task scheduler
Super User
Task scheduler - What is "Wait for idle for"?
I created a new Task in my task scheduler and I wanted it to be running only if the computer is idle for 10 min.
but then I saw this checkbox which I don't understand what it does :
The help say...
Task idle conditions - Win32 apps
A task can be handled in several ways when the computer enters an idle state. This includes defining an idle trigger or setting the idle conditions for when the task starts.
Thanks for the useful resources. That gives me a few ideas already. Would creating a scheduled task as part of an installer be a viable option? Feels a bit hacky to me but I’m not that experienced and it could be great solution for all I know. What do you think?
yes, some installers add tasks, usually for auto-updaters
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
that's not entirely reliable, unless you're also checking for things like media players telling Windows to not go to sleep
which the Idle thing in Task Scheduler does handle
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View