delphi内如何检测用户多长时间没有鼠标与键盘操作?

procedure TForm1.Timer1Timer(Sender: TObject);
var
  vLastInputInfo: TLastInputInfo;
begin
  vLastInputInfo.cbSize :
= SizeOf(TLastInputInfo);
  GetLastInputInfo(vLastInputInfo);
  Caption :
= Format('用户已经%d秒没有动键盘鼠标了',
    [(GetTickCount 
- vLastInputInfo.dwTime) div 1000]);
end;

原文地址:https://www.cnblogs.com/martian6125/p/9631486.html