Executar uma rotina após 30 segundos inativo

Top  Previous  Next

function SecondsIdle: DWord;

var

   liInfo: TLastInputInfo;

begin

   liInfo.cbSize := SizeOf(TLastInputInfo) ;

   GetLastInputInfo(liInfo) ;

   Result := (GetTickCount - liInfo.dwTime) div 1000;

end;

 

procedure TForm18.Timer1Timer(Sender: TObject);

begin

  if SecondsIdle > 30 then

  begin

    Timer1.Enabled := False;

    ShowMessage('Ficou mais 30 segundos parado');

  end;

end;