Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 18.05.05 20:31 
Hi, Delpher,

wie kann ich, timergesteuert, eine Prozedur nach einer bestimmten Zeit der Nichtaktivität (Tastatur, Maus) auslösen?

Einen Bildschirmschoner wollte ich nicht einsetzen.

Vielen Dank für Hilfe,
D. Annies
feivel3333
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190

W7
Delphi XE prof
BeitragVerfasst: Mi 18.05.05 21:05 
Hallöchen,

also, das kannst du wie folgt lösen:

Im Hauptformular deiner Anwendung setzt du in die OnCreate folgendes rein:

ausblenden Quelltext
1:
Application.OnIdle := IsIdle;					


Dabei ist die IsIdle-Prozedur namentlich von dir frei vergebbar. Du kannst sie genauso gut "Egon" anstatt von "IsIdle" nennen.

Anschließend schreibst du diese "IsIdle-Prozedur":

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TMainForm.IsIdle(Sender: TObject; var Done: Boolean);

begin
   TuWasTimer.Enabled := true;
end;


Sobald das System, bzw. die Applikation in den Idle-Zustand übergeht, also sich beruhigt hat, wird die IsIdle-Prozedur aufgerufen.
Wenn du dort einen TuWasTimer aktivierst, der auf einer von dir zu wählenden Zeit irgendetwas nach deinem Wunsch ausführt (dieser sollte natürlich beim Programmstart auf Enabled = false stehen), dann bist du schon fertig.

Gruß, Feivel
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 19.05.05 05:31 
Hi, Feivel!

Danke für deine schnelle Antwort, scheint genau das zu sein, was ich brauche.

Ich habe jetzt gleich 5 Stunden Aufsicht bei einer Abschlussklausur, da werde ich mal ein wenig proggen ...

Bis dann,
Detlef Annies
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 19.05.05 20:35 
Hi, feivel!

Leider, leider, ich bekomme (Delphi3prof) einen Error bei der Zeile

Application.OnIdle := IsIdle; - bei der Ausführung.

Hast du noch eine Idee?
Grüße aus Lübeck, D. Annies
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Do 19.05.05 20:40 
Was kommt denn für ein Fehler?
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 20.05.05 13:38 
Hi, WebSpace,

es wird klaglos kompiliert. Das Programm startet aber sofort mit einer
Exception: EAccessViolation im Modul buch.exe (Zugriffsverletzung)

Es scheint mir mit der globalen Variable Application : Tapplication zusammen zu hängen??

Viele Grüße erstmal, D. Annies
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 21.05.05 21:01 
Hi, Feivel, webspace et aliter,

kann es sein, dass Application.OnIdle "uses Variants" braucht?
Dann kann ich mit D3Prof wohl nichts werden, oder?

Grüße aus Lübeck, D. Annies
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Sa 21.05.05 22:33 
Hi, Delpher,
weiteres Nachdenken (Probieren, lesen) ergab:
Die variable Application habe ich gelöscht, aber das Prg "knallt" sofort bei dem
Eintrag in FormCreate:
Application.OnIdle := IdleHandler;

Was kann da nur los sein? Ich habe wirklich mehrere verschiedene Beiträge zu diesem Thema gelesen und absolut keinen Übertragungsfehler (mehr) drin!

Danke für Hilfe,
D. Annies
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mo 23.05.05 11:10 
Hmm... Probier' doch in allen deinen Delphi-Versionen mal folgendes aus:

(1) Neues Projekt erstellen
(2) Zum Code-Fenster wechseln
(3) Den ganzen Code löschen
(4) Folgenden Code reinschreiben:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure MyFormIsIdle(Sender: TObject; var Done: Boolean);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.MyFormIsIdle(Sender: TObject; var Done: Boolean);
begin
//code
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnIdle := MyFormIsIdle;
end;

end.


Wenn das Programm startet funktioniert's eigentlich schon. ;)