判断操作系统多久没有任何操作

代码
function StopTime: integer; //返回没有键盘和鼠标事件的时间
var
  LInput: TLastInputInfo;
begin
  LInput.cbSize :
= SizeOf(TLastInputInfo);
  GetLastInputInfo(LInput);
  Result :
= (GetTickCount() - LInput.dwTime) div 1000;  // 微妙换成秒
end;

procedure TForm1.Timer1Timer(Sender: TObject);    // Timer 事件
begin
if StopTime >= 60 then
  Showmessage(
'用户已经1分钟没有动键盘鼠标了!');
end;

 

posted on 2010-01-20 12:01  jxgxy  阅读(294)  评论(0编辑  收藏  举报

导航