Delphi 检测用户超过多长时间没有操作键盘或鼠标

procedure TForm1.Timer1Timer(Sender: TObject);
var
vLastInputInfo: TLastInputInfo;
begin
vLastInputInfo.cbSize :
= SizeOf(vLastInputInfo);
GetLastInputInfo(vLastInputInfo);
if GetTickCount - vLastInputInfo.dwTime > 5000 then
begin
timer1.Enabled:
= false;
showmessage(
'超过5秒,用户未动鼠标!');
end;
end;

你可能感兴趣的:(Delphi)