Recent

Author Topic: I don't understand TIdleTimer using  (Read 15278 times)

howardpc

  • Hero Member
  • *****
  • Posts: 3312
Re: I don't understand TIdleTimer using
« Reply #15 on: September 30, 2016, 12:16:26 pm »
I can't see that the order of setting these properties to False makes the slightest difference to subsequent behaviour.

totya

  • Hero Member
  • *****
  • Posts: 577
Re: I don't understand TIdleTimer using
« Reply #16 on: October 08, 2016, 12:58:59 am »
Hi!

Thanks for the answer!

rc.1990

  • Jr. Member
  • **
  • Posts: 54
Re: I don't understand TIdleTimer using
« Reply #17 on: August 03, 2018, 01:41:23 pm »
hello,
for your idle timer why do you not use the component tidletimer ( system components tab) ?
Blaazen in another post explains what is it :
Quote
Well, when TIdleTimer.AutoEnabled=False then it behaves just like normal TTimer.
If you switch to Enabled:=False and AutoEnabled:=True then (in default configuration, i.e. AutoStartEvent=itaOnIdle and AutoEndEvent=itaOnUserInput) this timer raises events on IDLE (= when nothing happens, i.e. you don't move move, no clicks, no keyboard input etc.)

so, to use this component in a form for no activity detection, for example put a tidletimer in your form with properties :
AutoEnabled :  True
AutoEndEvent :  itaOnUserInput
AutoStartEvent : itaOnIdle
Enabled : False
Interval : 60000

and for OnTimerEvent this procedure :
Code: [Select]
procedure TForm1.IdleTimer1Timer(Sender: TObject);
begin
  showmessage('no activity during one minut');
end;   

Friendly, J.P
Thanks all. Solved:
Code: Pascal  [Select]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   IdleTimer1.AutoEnabled:=True;
  4.   IdleTimer1.AutoEndEvent:=itaOnUserInput;
  5.   IdleTimer1.AutoStartEvent:=itaOnIdle;
  6.   IdleTimer1.Enabled:=False;
  7.   IdleTimer1.Interval:=5000;
  8. end;
  9.  
  10. procedure TForm1.IdleTimer1Timer(Sender: TObject);
  11. begin
  12.   ShowMessage('Application will be closed by inactivity.');
  13.   Application.Terminate;
  14. end;

dbannon

  • Hero Member
  • *****
  • Posts: 893
    • tomboy-ng, a rewrite of the classic Tomboy
Re: I don't understand TIdleTimer using
« Reply #18 on: August 03, 2018, 02:03:33 pm »
Well Done !
That looks like a great example to add to -
http://wiki.freepascal.org/TIdleTimer

 :D
Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng