如何在 UWP 中检测用户空闲? [英] How to detect user idle in UWP?

查看:28
本文介绍了如何在 UWP 中检测用户空闲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在 UWP 中检测用户空闲.我的意思不是用户闲置应用程序的情况,而是整个系统/操作系统:没有键盘输入,没有鼠标操作,没有触摸即使没有关注应用程序或应用程序被最小化. >

我找到了一些关于它的其他帖子.像这样:如何检查用户是否空闲在 UWP 上?它使用以下方法:

Window.Current.CoreWindow.PointerMoved += onCoreWindowPointerMoved;

我测试发现,如果我的鼠标移动到应用程序窗口之外,则不会执行 onCoreWindowPointerMoved().这意味着该方法无法检测到整个系统上的用户空闲.

解决方案

如何在 UWP 中检测用户空闲?

出于安全原因,我们无法在 UWP 平台中实现此功能,但我们可以在旧版 win32 应用程序中实现此功能,并使用 FullTrustProcessLauncher 运行 win32 应用程序以检测系统空闲.然后使用 AppService 将状态传递给 UWP 应用.有关更多信息,请参阅此教程

I want to know how to detect user idle in UWP. I mean not the case user idle for the app, but for the whole system/OS: no keyboard input, no mouse operation, no touch even when no focus on the app or app is minimized.

I find some other post about it. Like this: How to check if user is idle on UWP? And it uses below method:

Window.Current.CoreWindow.PointerMoved += onCoreWindowPointerMoved;

I tested and found that if my mouse moves outside of the app window, then onCoreWindowPointerMoved() will not be executed. It means this method can not detect user idle on the whole system.

解决方案

How to detect user idle in UWP?

For security reason, we could not implement this in UWP platform, But we could implement this in legacy win32 app, and use FullTrustProcessLauncher to run the win32 app to detect the system idle. then use AppService pass the status to UWP app. For more please refer this tutorial

这篇关于如何在 UWP 中检测用户空闲?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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