检测 Windows 通用应用程序上的用户是否空闲 [英] Detect if user Idle on windows universal app
问题描述
我正在为 Windows 10 通用应用程序(仅限移动和桌面设备系列)开发一个类库.如果用户空闲(没有触摸、鼠标移动、按键等)x 秒,我需要调用一个事件.这个方法可以在android上解决这个问题.但是我在 windows UWP 上找不到解决方案.
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.
UWP 中是否有可用的 API 来实现这一点?
Is there an API available in UWP to achieve this?
推荐答案
您可以在应用的 CoreWindow 上使用各种事件检测全局输入:
You can detect global input with various events on the app's CoreWindow:
使用 CoreWindow.PointerPressed、PointerMoved 和 PointerReleased 进行触摸和鼠标输入.
Touch and mouse input with CoreWindow.PointerPressed, PointerMoved, and PointerReleased.
键盘输入:KeyUp 和 KeyDown(软键)和 CharacterReceived(用于通过和弦和文本建议生成的字符)
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.
这篇关于检测 Windows 通用应用程序上的用户是否空闲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!