检测到用户远离PC机与.NET检测到、用户、NET、PC

2023-09-04 00:47:41 作者:装瞎爱人

我有一个桌面应用程序中,我想知道两件事情:

I have a desktop application in which I would like to know two things:

是对用户当前在PC(更具体地说,是他提供任何输入到PC)上,所以如果需要,我可以改变他的状态为离开;和 在运行时,现在的屏幕保护程序,这样我就可以在这段时间内完成更多的CPU密集型的工作。

我使用C#/。NET。建议你将如何解决这两个任务?

I'm using C#/.NET. How would you suggest to tackle these two tasks?

注意:WIN32调用会一样好,以及任何非托管code解决方案

NOTE: WIN32 invocation will be just as good, as well as any unmanaged code solution.

推荐答案

的 http://dataerror.blogspot.com/2005/02/detect-windows-idle-time.html

^检测到Windows空闲时间。 :)

^ Detect Windows Idle Time. :)

的启用此功能是 GetLastInputInfo()的Win32 API 和LASTINPUTINFO Win32的结构。

The enabler for this feature is the GetLastInputInfo() Win32 API and the LASTINPUTINFO Win32 structure.