如何计算系统空闲超时并使机器进入睡眠状态? [英] How to calculate system idle time out and put the machine to sleep?

查看:51
本文介绍了如何计算系统空闲超时并使机器进入睡眠状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么可以提供系统范围内的最后用户输入信息的吗?我们希望使用C#获取所有会话中系统的空闲时间,如果X分钟内没有人使用计算机,则使计算机进入睡眠状态.

Is there anything that provides a system-wide last user input information? We want to use C# to get the idle time for the system across all sessions and put the machine to sleep if nobody is using the machine for X minutes.

似乎GetLastInputInfo是特定于用户的. http://msdn.microsoft.com/en-us/library/ms646302(VS.85).aspx

It appears that GetLastInputInfo is user specific. http://msdn.microsoft.com/en-us/library/ms646302(VS.85).aspx

推荐答案

您可以使用Windows 任务空闲条件

You can use the Windows Task Scheduler and register a Task that's launched when the system is idle. That's the best way, as it's no so obvious to determine the idleness of a system (check out the article at least to get a grasp of what it means). You can also protect task using security, etc. See here for more information on this: Task Idle Conditions

要使用C#编写任务计划程序,可以使用各种包装器.这里至少是一个:任务计划程序托管包装器

To program the task scheduler in C#, you can use various wrapper. Here is at least one: Task Scheduler Managed Wrapper

这篇关于如何计算系统空闲超时并使机器进入睡眠状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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