检测用户是否在 Windows 通用应用程序上空闲 [英] Detect if user Idle on windows universal app

查看:23
本文介绍了检测用户是否在 Windows 通用应用程序上空闲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆