Autor Beitrag
Safran
Hält's aus hier
Beiträge: 8

Win XP
Delphi 7
BeitragVerfasst: Fr 20.01.06 19:12 
Hallo,

ich bin noch ein ziehmlicher Anfänger. Ich habe jetzt ein kleines Programm geschrieben das mein Mauszeiger in gewissen Zeitabständen wiederholt, allerdings ist mir bewusst das es unsauber ist, denn es verbraucht ziehmlich viel Resourchen.

Kann mir jemand einen kleinen Tipp zur Verbesserung geben? Danke im Vorraus!

ausblenden 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:
procedure Delay(Zeit: longint);
  var Zeit1,zeit2 :longint;
    begin
      Zeit1:= Gettickcount;

      repeat
        zeit2:= gettickcount;
        application.ProcessMessages;
      until (zeit2-zeit1 > zeit);
    end;

procedure TForm1.Button1Click(Sender: TObject);
  begin

    repeat

      begin
        Delay(15000);
        Mouse.CursorPos := Point(Mouse.CursorPos.x + 10, Mouse.CursorPos.y + 10);
        a :=0;
      end;

    until a>0;

  end;
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 20.01.06 20:20 
Statt dem Delay einen Timer verwenden. Einfach mal nach TTimer suchen...

AXMD
Jetstream
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 222



BeitragVerfasst: Mo 30.01.06 13:45 
Deine Delay Prozedur sieht ja richtig eklig aus :)

Setz dir doch einfach nen Timer in die Form, da schreibste dann nur noch
ausblenden Delphi-Quelltext
1:
Mouse.CursorPos := Point(Mouse.CursorPos.x + 10, Mouse.CursorPos.y + 10);					

rein, und dann stellste noch dein Delay in den Properties des Timers ein.
Fertsch.
ghost_assassin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 18



BeitragVerfasst: Mi 08.02.06 14:15 
Zitat:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
    repeat   
      begin  
      Delay(15000);  
      Mouse.CursorPos := Point(Mouse.CursorPos.x + 10, Mouse.CursorPos.y + 10);  
      a :=0;  
      end;  
    until a>0;


das führt unweigerlich zu einer
endlosschleife...
wie soll denn a jemals größer
als 0 werden, wenn du immer
einen schritt vorher a auf 0 setzt
ergo: er arbeitet immer wieder deine
repeat schleife ab, ohne ein ende

kein wunder das du 100% systemlast
hast...
Mustafa
Hält's aus hier
Beiträge: 6

Win 2000/XP
Delphi 7/.NET
BeitragVerfasst: Do 09.02.06 03:42 
Hallo,

warum benutzt du nicht den befehl "sleep(msek)" ?.
Es funktioniert super und verbraucht nicht die bohne !
Neidhard von Reuental
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 268

XP
BDS 2006 Prof
BeitragVerfasst: Do 09.02.06 08:08 
mit sleep wird die ganze anwendung gestopt, ein zugriff auf die form ist dann nicht mehr möglich. bei zeitaufgaben sollte man immer einen timer verwenden. der wird auch ausgeführt wenn die anwendung grad mal nicht aktiv ist.
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: So 19.02.06 17:01 
Titel: Was ist Mouse für ein Variable?
Hallo,

Was ist Mouse denn für eine globale Variable und welcher typ?
Green
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: So 19.02.06 20:36 
sieht eher nach nem objekt aus... ;)
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 19.02.06 20:42 
Mouse.CursorPos := Point(Mouse.CursorPos.x + 10, Mouse.CursorPos.y + 10);Ich nehme mal an TPoint oder ein eigenes Record aus TPoints...