简体   繁体   English

在UWP中检测空闲用户

[英]Detecting idle user in UWP

I would like to know when the user is idle to perform an action, so I decided that a good start would be to attach to the PointerMoved event in my Page . 我想知道用户何时空闲以执行操作,因此我认为一个好的开始就是附加到我的PagePointerMoved事件。 Every time the mouse cursor is moved, the counter is reset. 每次移动鼠标光标时,计数器都会重置。

The problem is that my Page contains a WebView control that shows a website. 问题是我的Page包含一个显示网站的WebView控件。 It covers almost the whole part of the screen. 它几乎涵盖了整个屏幕部分。 I have observed that when I move the mouse cursor, the PointerMoved event isn't raised when it's over the WebView . 我观察到当我移动鼠标光标时, PointerMoved事件在WebView时不会被引发。

But it's even worse: the same happens when I add a handler to myWebView.PointerMoved . 但更糟糕的是:当我向myWebView.PointerMoved添加处理程序时myWebView.PointerMoved发生同样的情况。 It doesn't raise any event! 它不会引发任何事件!

Maybe I'm doing it wrong. 也许我做错了。 What can I do to detect when the user is idle? 如何检测用户何时空闲? Am I using the wrong method? 我使用了错误的方法吗?

I just tried it even via the CoreWindow object and it's PointerMoved event but even that one isn't fired with the webview. 我只是通过CoreWindow对象尝试它,它是PointerMoved事件,但即使是那个也不会被webview触发。

Maybe background task with single proces model can let you accomplise your scenario? 也许单一过程模型的后台任务可以让你完成你的场景?

The background task model contains triggers for userpresent and useraway: 后台任务模型包含userpresent和useraway的触发器:

new SystemTrigger(SystemTriggerType.UserPresent, false);
new SystemTrigger(SystemTriggerType.UserAway, false);

And with the single proces model you can make sure your app getting called and not a background task in an other proces: https://blogs.windows.com/buildingapps/2016/06/07/background-activity-with-the-single-process-model 使用单一过程模型,您可以确保您的应用程序被调用,而不是其他过程中的后台任务: https//blogs.windows.com/buildingapps/2016/06/07/background-activity-with-the-单过程的模型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM