function LastInput: DWord;
var
LInput: TLastInputInfo;
begin
LInput.cbSize := SizeOf(TLastInputInfo);
GetLastInputInfo(LInput);
Result := GetTickCount - LInput.dwTime;
end;
然后弄个定时器
procedure TForm1.Timer1Timer(Sender: TObject);
var
Llast: Cardinal;
begin
Llast := LastInput;
if Llast >=10 * 1000 100 then begin
try
// 提示已经有10秒没动键盘和鼠标了
except
end;
end;
end;