C# - 检测上次用户与操作系统交互的时间 [英] C# - Detect time of last user interaction with the OS

查看:28
本文介绍了C# - 检测上次用户与操作系统交互的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个小型托盘应用程序,需要检测用户上次与其机器交互的时间,以确定他们是否空闲.

I'm writing a small tray application that needs to detect the last time a user interacted with their machine to determine if they're idle.

有什么方法可以检索用户上次移动鼠标、击键或以任何方式与机器交互的时间吗?

Is there any way to retrieve the time a user last moved their mouse, hit a key or interacted in any way with their machine?

我认为 Windows 显然会跟踪它以确定何时显示屏幕保护程序或关闭电源等,所以我假设有一个 Windows API 可以自己检索它?

I figure Windows obviously tracks this to determine when to display a screen saver or power down, etc, so I'm assuming there's a Windows API for retrieving this myself?

推荐答案

GetLastInputInfo.记录在 PInvoke.net.

这篇关于C# - 检测上次用户与操作系统交互的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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