Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if user Idle on windows universal app

I'm developing a class library for windows 10 universal apps (mobile and desktop device families only). I need to invoke an event if the user has been idle(no touch, mouse move, key press etc) for x number of seconds. This method can be used to solves this problem on android. But I couldn't find a solution on windows UWP.

Is there an API available in UWP to achieve this?

like image 636
Kavinda Gayashan Avatar asked Jun 29 '15 11:06

Kavinda Gayashan


People also ask

How do I know if my computer is idle?

You could use GetLastInputInfo to check how long the user has been idle and SystemParametersInfo to check if a screensaver is active. Here is a similar case for you as a reference. It includes the usage of the GetLastInputInfo.

What is idle Detection API?

The Idle Detection API provides a means to detect the user's idle status, active, idle, and locked, specifically, and to be notified of changes to idle status without polling from a script.


1 Answers

You can detect global input with various events on the app's CoreWindow:

Touch and mouse input with CoreWindow.PointerPressed, PointerMoved, and PointerReleased.

Keyboard input: KeyUp and KeyDown (the soft keys) and CharacterReceived (for characters generated via chords & text suggestions)

Use these to detect the user is active and idle out if it goes too long without any of these events.

like image 173
Rob Caplan - MSFT Avatar answered Oct 22 '22 00:10

Rob Caplan - MSFT