windows-store-apps - 检测 Windows 通用应用程序上的用户是否空闲

标签 windows-store-apps win-universal-app windows-10 idle-processing

我正在为 Windows 10 通用应用程序(仅限移动和桌面设备系列)开发一个类库。如果用户空闲(没有触摸、鼠标移动、按键等)x 秒,我需要调用一个事件。 This method可以用来在android上解决这个问题。但我在 Windows UWP 上找不到解决方案。

UWP 中是否有可用的 API 来实现这一点?

最佳答案

我知道这确实是个老问题,但我认为您现在可以使用 RegisterBackgroundTask 获得相同的结果
只需设置:new TimeTrigger(15, false) //For time trigger Linknew SystemCondition(SystemConditionType.UserNotPresent)) //And so you want to know so user is not present Link
App.xaml.cs 中的示例用法:

var builder = new BackgroundTaskBuilder();
builder.Name = "Is user Idle";
builder.SetTrigger(new TimeTrigger(2, false)); //two mins
builder.AddCondition(new SystemCondition(SystemConditionType.UserNotPresent));
// Do not set builder.TaskEntryPoint for in-process background tasks
// Here we register the task and work will start based on the time trigger.
BackgroundTaskRegistration task = builder.Register();
task.Completed += (sender, args) =>
{
    //Handle user not present (Idle) here.
};

关于windows-store-apps - 检测 Windows 通用应用程序上的用户是否空闲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31114031/

相关文章:

xaml - 拉伸(stretch)的 Windows 应用商店 Logo

c# - Windows Phone 8.1 RT - 保存和加载页面状态

c++ - UTF8 文本编码 - Windows Phone 8.1 C++

SQLite 文件的位置 Windows 10 通用应用程序

php - Windows 10 上的 WordPress

Powershell:启动进程不将参数传递给 cmd.exe

c# - 在漫游设置中存储复杂数据类型

c# - 在设计器模式下,来自 Nuget 的隐形 Windows 8.1 自定义控件

c# - PDFNet Nuget 库与 UAP Version=v10.0 不兼容

windows - 如何更改 UWP 中 ListView 中默认选定的焦点背景颜色?