Delphi 检测鼠标键盘多久没有活动

function GetInputAwayTime():DWORD;  
var
  lpi:TLastInputInfo;
begin
  lpi.cbSize := sizeof(lpi);
  GetLastInputInfo(lpi);
  Result := Round((GetTickCount()-lpi.dwTime)/1000);
end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin
Caption := IntToStr(GetInputAwayTime)
end;
原文地址:https://www.cnblogs.com/windson/p/12587376.html