如何在c#中获得系统空闲持续时间? [英] How to get system idle time duration in c#?

查看:94
本文介绍了如何在c#中获得系统空闲持续时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何在c#中获得系统空闲时间?

Hi,

How to get system idle duration in c#?

推荐答案

我建​​议你去找jquery。那么,我们如何计算用户是否空闲。很明显,直到他/她移动鼠标或按下键盘上的任何键。因此,解决方案是继续观察鼠标移动和按键事件。很快发生任何这些事件,重置空闲时间。这是一个示例代码







var idleTime = 0;


I suggest to you to go for jquery instead.So, how do we calculate if the user is idle. Obeviously, until he/she has moved the mouse or pressed any key from the keyboard. So the solution is keep observing the mousemove & keypress event. Soon any of these event occurs, reset the idle time. Here is a sample code



var idleTime = 0;


(document).ready(function(){

//每分钟增加空闲时间计数器。

var idleInterval = setInterval(timerIncrement,60000); // 1分钟



//鼠标移动时将空闲计时器归零。
(document).ready(function () {
//Increment the idle time counter every minute.
var idleInterval = setInterval(timerIncrement, 60000); // 1 minute

//Zero the idle timer on mouse movement.


(this).mousemove(function(e){

idleTime = 0;

});
(this).mousemove(function (e) {
idleTime = 0;
});


这篇关于如何在c#中获得系统空闲持续时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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