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: Fr 13.03.09 19:00 
Hi, Delpher,

nach ca. 10 Minuten des Nichtstuns mit der Tastatur oder mit der Maus läuft der Code ab. Er soll allerdings eigentlich nur einmal ausgeführt werden, das reicht ja.

Ich habe jetzt den Rechner übers Wochenende durchlaufen lassen und durfte mich fast totklicken, bis ich den Dialog hinter mir hatte.

Wer weiß, was ich da ändern muss?

Code:

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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
procedure TForm1.Timer1Timer(Sender: TObject);
var TempForm : TForm;
    Image    : TImage;
begin
  Timer1.Enabled := false;
  TempForm := TForm.Create(self);
  try
    TempForm.WindowState := wsmaximized;
    Image := TImage.Create(TempForm);
    Image.Parent := TempForm;
    Image.Picture.LoadFromFile(label30.Caption + 'Schluessel.jpg');
    Image.SetBounds(10,10,980,680); Image.Stretch := true;
    TempForm.Show;
    messagedlgpos('Zeitüberschreitung!', mtInformation, [mbOk], 0,450,530);
  finally
    TempForm.Release; //nicht free!
  end;
  form1.passwd(self);
end;

procedure tform1.passwd(sender:tobject);
begin
  form1.groupbox9.align := alclient;
  form1.groupbox9.visible := true; form1.groupbox9.bringtofront;
  form1.edit14.text := '';
  timer1.Enabled := true;
end;

function KeyboardProc(nCode:integer; wParam:longint; lParam:longint):longint; stdcall;
begin
  result := CallNextHookEx(KeyboardHook, ncode, wparam, lparam);
  form1.Timer1.enabled := false;  form1.Timer1.enabled := true;
end;
function MouseProc(nCode:integer; wparam: longint; var MouseHookStruct: TMouseHookStruct):longint; stdcall;
begin
  result := CallNextHookEx(MouseHook, nCode, wparam, longint(@MouseHookStruct));
  form1.timer1.enabled := false; form1.Timer1.enabled := true;
end;

procedure TForm1.FormCreate(Sender: TObject);        // Initialisierungen
begin
  windowstate := wsmaximized;
  KeyboardHook := SetWindowsHookEx(WH_KEYBOARD, @KeyboardProc, 0, GetCurrentThreadID);
  MouseHook    := SetWindowsHookEx(WH_MOUSE, @MouseProc, 0, GetCurrentThreadID);
  timer1.enabled := false; timer1.interval := 10*60000{10 min} timer1.enabled := true;
  // usw. ...
end;


Vielen Dank für Ideen/AbHilfe,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 13.03.09 19:02 
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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
procedure TForm1.Timer1Timer(Sender: TObject);
var TempForm : TForm;
    Image    : TImage;
begin
  Timer1.Enabled := false;
  TempForm := TForm.Create(self);
  try
    TempForm.WindowState := wsmaximized;
    Image := TImage.Create(TempForm);
    Image.Parent := TempForm;
    Image.Picture.LoadFromFile(label30.Caption + 'Schluessel.jpg');
    Image.SetBounds(10,10,980,680); Image.Stretch := true;
    TempForm.Show;
    messagedlgpos('Zeitüberschreitung!', mtInformation, [mbOk], 0,450,530);
  finally
    TempForm.Release; //nicht free!
  end;
  form1.passwd(self);
end;

procedure tform1.passwd(sender:tobject);
begin
  form1.groupbox9.align := alclient;
  form1.groupbox9.visible := true; form1.groupbox9.bringtofront;
  form1.edit14.text := '';
  timer1.Enabled := true;
end;

function KeyboardProc(nCode:integer; wParam:longint; lParam:longint):longint; stdcall;
begin
  result := CallNextHookEx(KeyboardHook, ncode, wparam, lparam);
  form1.Timer1.enabled := false;  form1.Timer1.enabled := true;
end;
function MouseProc(nCode:integer; wparam: longint; var MouseHookStruct: TMouseHookStruct):longint; stdcall;
begin
  result := CallNextHookEx(MouseHook, nCode, wparam, longint(@MouseHookStruct));
  form1.timer1.enabled := false; form1.Timer1.enabled := true;
end;

procedure TForm1.FormCreate(Sender: TObject);        // Initialisierungen
begin
  windowstate := wsmaximized;
  KeyboardHook := SetWindowsHookEx(WH_KEYBOARD, @KeyboardProc, 0, GetCurrentThreadID);
  MouseHook    := SetWindowsHookEx(WH_MOUSE, @MouseProc, 0, GetCurrentThreadID);
  timer1.enabled := false; timer1.interval := 10*60000{10 min} timer1.enabled := true;
  // usw. ...
end;


überleg dir mal die sinnhaftigkeit der markierten zeilen!

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Fr 13.03.09 19:18 
Zurücksetzen des Timers?!
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 13.03.09 19:29 
wozu den timer zurücksetzen?

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Fr 13.03.09 19:32 
damit er nochmal den Interval läuft?
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 13.03.09 19:37 
hmmm, k stimmt.

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Fr 13.03.09 21:04 
Nach dem ersten Aufruf den Timer deaktivieren, und nicht in passwd wieder neu aktivieren?

_________________
PROGRAMMER: A device for converting coffee into software.
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 13.03.09 21:52 
Hi, ihr aktiven,

den Vorschlag von Xentar habe ich eben ausprobiert, (natürlich mit Timer.intervall = 1 min), aber gleiches Bild, gleicher Ton.

Trotzdem erstmal danke,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
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: So 15.03.09 19:59 
Hi, Delpher,

noch nie konnte mir hier nicht geholfen werden (= immer konnte mir hier geholfen werden)

bloß diesmal (noch) nicht?
Soll ich den Timer verwerfen, oder gibt es noch andere Ideen? Ich bin mit meinem Latein am Ende (siehe Sinnspruch).

Danke für eine Idee,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: So 15.03.09 20:12 
Dann musst du uns vielleicht auch auf dem Laufenden halten, was du schon alles probiert hast, und wie du dies umgesetzt hast..?!

Was soll denn das ganze werden? Vielleicht reicht es, dein Programm als Bildschirmschoner einzurichten, dann kümmert sich Windows um den Aufruf?

_________________
PROGRAMMER: A device for converting coffee into software.
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: Mo 16.03.09 12:22 
Hi, Xentar,

tja, ich habe halt die ganze Zeit mit Timer1.enabled und .disabled herumprobiert - ohne Erfolg, da ohne Strategie.

Der Sinn ist es, dass nach 10-minütigem Nichtstun mit der Tastatur/Maus das Programm erst weiterläuft, wenn das passwort erneut eingegeben wird.

Bis dann, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Mo 16.03.09 12:40 
Merk dir doch im Hook Now() und lass den Timer durchlaufen.

Dort vergleichst du mit now().

Und wenn now() - LastInputDateTime > (1 / 24 / 60) * 10 ...

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mo 16.03.09 13:17 
Warum eigentlich kein ShowModal und am Ende Form.Free?

_________________
PROGRAMMER: A device for converting coffee into software.
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: Mo 16.03.09 20:15 
Hi, Xentar,

ich habe jetzt geändert und deine beiden Vorschläge eingebracht, leider noch ohne "Durchbruch", aber es ist so auf jeden Fall erstmal besser.

@Hazard999:
Ich habe leider keine Ahnung, wie dieser Code einzubauen ist.

Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
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: Mo 16.03.09 20:50 
Hallo, Michael (elundril),

so, jetzt habe ich mal die Zeilen timer1.enabled := false; timer1.enabled := true; herausgenommen, und siehe da, jetzt funktioniert es!

Etwas werde ich allerdings noch abwarten, aber dann kann ich wohl wieder aufatmen.
Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
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: Di 17.03.09 19:51 
So, ich habe jetzt eine globale Variable namens PrgStop (smallint) genommen und damit geht es; code kommt nach, falls gewünscht,

Grüße, Detlef

_________________
ut vires desint, tamen est laudanda voluntas