C
C#3y ago
Bunda

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
Becquerel
Becquerel3y ago
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
jcotton42
jcotton423y ago
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...
jcotton42
jcotton423y ago
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.
Bunda
BundaOP3y ago
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?
Trinitek
Trinitek3y ago
yes, some installers add tasks, usually for auto-updaters
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
jcotton42
jcotton423y ago
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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server