I don't understand TIdleTimer using lazarus / 31-LCL ---------------------------------------------------------------------- xamsin · 2012-09-02 18:11 Hallow. Could anybody tell me about using of this stupid component.  I not understand about propertis FireOnIdle? AutoEnabled? (AutoStartEvent? and AutoEndEvent? what about thay values, what are thay meen. (itaOnUserInput,itaOnIdleEnd,itaOnIdle)). May be some examples usind TIdleTimer. (I not found this in forum or lasarus wiki, it's a problem of Lazarus not enougth Documentation for dummies  ). ---------------------------------------------------------------------- typo · 2012-09-02 20:23 Stupid component? Dummies should have a little more respect. http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tidletimer.html ---------------------------------------------------------------------- eny · 2012-09-02 21:22 Quote from: xamsin on September 02, 2012, 08:11:36 pmHallow. Could anybody tell me about using of this stupid component. Ah you must be a relative of Anna. http://www.lazarus.freepascal.org/index.php/topic,18056.msg101287.html #msg101287 ---------------------------------------------------------------------- Leledumbo · 2012-09-02 21:58 Quote(I not found this in forum or lasarus wiki, it's a problem of Lazarus not enougth Documentation for dummies   ).At least not for this component, as typo has pointed out. You can also press F1 on it (assuming you're using at least latest 1.0 version). ---------------------------------------------------------------------- typo · 2012-09-03 00:12 We do not owe you anything. If Lazarus is useful to you, you are welcome. If not, simply don't use it. ---------------------------------------------------------------------- xamsin · 2012-09-03 03:01 Hi, typo. Could you post some examples using this component.  i have read little about this component here http://lazarus- ccr.sourceforge.net/docs/lcl/extctrls/tidletimer.html before i asking my question. so if I wrote  AutoEnabled:=true; and  procedure TForm1.IdleTimer1StopTimer(Sender: TObject);  begin   form1.Close;  end;  My form closes on start! AutoStartEvent=itaonidle, AutoEndEvent=itaonIdleEnd  If I set FireOnIdle:=true; Timer never stop't.  ????? So may be some examles..... ---------------------------------------------------------------------- typo · 2012-09-03 10:46 Quote it's a problem of Lazarus not enougth Documentation. How about you post some documentation? Quote ????? So may be some examles..... How about you post some example? ---------------------------------------------------------------------- Blaazen · 2012-09-03 11:32 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.) I attached a small app. to testing. It is very easy, you can do it yourself too, it takes a few minutes to create such app. ---------------------------------------------------------------------- ludob · 2012-09-03 11:50 Drop a TIdleTimer and a label on a form. Set TIdleTimer.AutoEnabled to true and Interval to 5000.  Add following code: Code: [Select]procedure TForm1.IdleTimer1StartTimer(Sender: TObject); begin label1.caption:='start'; end; procedure TForm1.IdleTimer1StopTimer(Sender: TObject); begin label1.caption:='stop'; end; procedure TForm1.IdleTimer1Timer(Sender: TObject); begin label1.caption:='event'; end; and you'll see immediately what it is all about. Much quicker than writing a post complaining about lack of documentation / examples and it exercises the brain a little in the same time. As the name says TIdleTimer is a timer that runs when the app is idle. OnStartTimer is triggered by default when the app is idle (itaOnIdle) and the timer starts, OnStopTimer when the app detects user input (itaOnUserInput) and consequently stops    When you leave the app idle for Interval millisecs OnTimer is triggered which is identical to TTimer. I'll let you guess what the different AutoEndEvent/AutoEndEvent settings are. Hint: idle refers to the state of the app, not the timer So setting form1.Close in OnStopTimer means (ifAutoEndEvent=itaonIdleEnd) that you close the form as soon as the app has been idle (event queue empty) and a new event comes in which is very frequent. ---------------------------------------------------------------------- BigChimp · 2012-09-03 16:30 Perhaps the OP would like to donate some of the time the others' responses saves him by writing a wiki article on TIdleTimer (in English or his own language) so dummies that need documentation for this stupid component can find it... ---------------------------------------------------------------------- rc.1990 · 2016-09-27 05:49 First, my condolences for BigChimp and thanks to all help he provided. Studying this thread, I have made a small projet to learn how TIdleTimer works. The OnStopTimer and OnTimer events are working as expected, but the OnStartTimer event keeps firing as soon as either OnStopTimer or OnTimer events are fired and not after I stoped using Mouse or Keyboard input and computer becoming really idle. Is this the expected behavior for OnStartTimer event? Shouldn't Label1 keeping "stop" until computer becoming idle and then Label1 been changed to "start" counting time until next OnTimer event to be fired? My small project for testing is attached. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit unit2; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,  ExtCtrls; type   { TForm1 }   TForm1 = class(TForm)    Edit1: TEdit;  IdleTimer1: TIdleTimer;    Label1: TLabel;    Label2: TLabel;    procedure FormCreate(Sender: TObject);    procedure IdleTimer1StartTimer(Sender: TObject);    procedure IdleTimer1StopTimer(Sender: TObject);    procedure IdleTimer1Timer(Sender: TObject);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin  IdleTimer1.AutoEnabled := True;  IdleTimer1.AutoStartEvent := itaOnIdle;  IdleTimer1.AutoEndEvent := itaOnUserInput;  IdleTimer1.Interval := 3000;  IdleTimer1.Enabled := False;end; procedure TForm1.IdleTimer1StartTimer(Sender: TObject);begin    label1.caption:='start';end; procedure TForm1.IdleTimer1StopTimer(Sender: TObject);begin    label1.caption:='stop';    label2.caption:='stop';end; procedure TForm1.IdleTimer1Timer(Sender: TObject);begin    label1.caption:='event';    label2.caption:='';end; end. ---------------------------------------------------------------------- molly · 2016-09-27 13:55 As far as i am able to see from writing the events in a memo - Having AutoEnabled active means that the AutoStartEvent and AtoEndEvent properties takes care of 'activating' or 'stopping' the timer. - The timer is enabled (e.g. starts counting) when idle is encountered (in case you have itaOnIdle as the AutoStartEvent) - It 'stops' counting when the AutoEndEvent is encountered (in your case itaOnUserInput) and will not 'activate' the timer but only starts counting again until things become idle (itaOnIdle) again. This process is a continues process, because the moment you stop providing userinput the itaOnIdle comes into play again, which 'enables' the timer, counts down and fires the timer event with the provided interval. So, whenever the StartTimer event fires, you can be certain that things are "idle". The timer is enabled and starts counting. If in between you start giving user input again, the counting is interrupted and the timer event will not fire. Conclusion: afaik this is the expected behaviour. ---------------------------------------------------------------------- rc.1990 · 2016-09-27 14:05 Thanks molly. ---------------------------------------------------------------------- howardpc · 2016-09-27 17:03 The attached project lets you explore the properties and events of TIdleTimer further. ---------------------------------------------------------------------- totya · 2016-09-29 17:47 Hi! My question is, what is the suggested method order in the beginning of the OnTimer event? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i AutoEnabled:=False;Enabled:=false; or Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Enabled:=false;AutoEnabled:=False; ---------------------------------------------------------------------- howardpc · 2016-09-30 10:16 I can't see that the order of setting these properties to False makes the slightest difference to subsequent behaviour. ---------------------------------------------------------------------- totya · 2016-10-07 22:58 Hi! Thanks for the answer! ---------------------------------------------------------------------- rc.1990 · 2018-08-03 11:41 Quote from: Jurassic Pork on July 24, 2013, 01:42:04 amhello, for your idle timer why do you not use the component tidletimer ( system components tab) ? Blaazen in another post explains what is it : QuoteWell, 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.PThanks all. Solved: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);begin  IdleTimer1.AutoEnabled:=True;  IdleTimer1.AutoEndEvent:=itaOnUserInput;  IdleTimer1.AutoStartEvent:=itaOnIdle;  IdleTimer1.Enabled:=False;  IdleTimer1.Interval:=5000;end; procedure TForm1.IdleTimer1Timer(Sender: TObject);begin  ShowMessage('Application will be closed by inactivity.');  Application.Terminate;end; ---------------------------------------------------------------------- dbannon · 2018-08-03 12:03 Well Done ! That looks like a great example to add to - http://wiki.freepascal.org/TIdleTimer Davo ---------------------------------------------------------------------- jerrylaz · 2020-11-21 15:19 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.