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

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;

http://www.cnblogs.com/jxgxy/archive/2010/01/20/1652258.html

原文地址:https://www.cnblogs.com/findumars/p/4964831.html