Recent

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

howardpc

  • Hero Member
  • *****
  • Posts: 4144
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: 720
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: 2786
    • 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 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

jerrylaz

  • Newbie
  • Posts: 5
Re: I don't understand TIdleTimer using
« Reply #19 on: November 21, 2020, 04:19:08 pm »
I have attached a small program for testing out the TIdleTimer.
The program consist of a loop which can be turn ON or OFF. It is used to make the program to appear busy when turned ON.
You can change the properties of the TIdleTimer on the fly and see how its OnStartTimer/OnStopTimer/OnTimer events behave.
Depending on the AutoStartEvent and AutoEndEvent mode, the OnStartTimer and OnStopTimer events can fire hundreds of times every second.
When the AutoStartEvent condition is met, it will auto turn on the timer and the OnTimer event will fire after the interval set and the OnTimer event will repeats itself until the AutoEndEvent condition has been met.

AutoStartEvent and AutoEndEvent works only if AutoEnabled is true.
When AutoEnabled is false, TIdleTimer works exactly like a normal TTimer.
« Last Edit: November 21, 2020, 04:38:10 pm by jerrylaz »

 

TinyPortal © 2005-2018