Autor Beitrag
andras
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 460

Win XP, Win Vista Home Premium, Ubuntu Dapper Drake
Delphi 2005 Pers
BeitragVerfasst: Do 27.10.05 11:06 
hallo!
ich hab folgenden quelltext mal eingetippt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
  Sleep(500);
   GetCursorpos(p);
   SetCursorPos(310,33);
   mouse_event(MOUSEEVENTF_Leftdown, 310,3300);
   mouse_event(MOUSEEVENTF_Leftup, 310,3300);
   Sleep(1);
   SetCursorPos(320,138);
   mouse_event(MOUSEEVENTF_Leftdown, 320,13800);
   mouse_event(MOUSEEVENTF_Leftup, 320,13800);
   Sleep(1);
   keybd_event(VK_NUMPAD2,0,0,0);
   keybd_event(VK_NUMPAD2,0,KEYEVENTF_KEYUP,0);
   Sleep(1);
   keybd_event(VK_NUMPAD0, 000);
   keybd_event(VK_NUMPAD0, 0, KEYEVENTF_KEYUP, 0);
   Sleep(1);
   SetCursorPos(597,357);
   mouse_event(MOUSEEVENTF_Leftdown, 597,35700);
   mouse_event(MOUSEEVENTF_Leftup, 597,35700);

das prog macht nicht mehr als den cursor zu versetzte und zu klicken und mal 2 tasten zu drücken. so wie ichs oben gemacht hab funktionierts noch.
wenn man aber alle sleep-anweisungen weglässt, hört das prog manchmal in der mittd auf oder drückt keine tasten oder lässt teile aus,... kurz, bei jedem mal kompilieren ists anders. WARUM??

Moderiert von user profile iconKlabautermann: Code- durch Delphi-Tags ersetzt
blaueled
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 133

Win XP
D5
BeitragVerfasst: Do 27.10.05 11:13 
Hallo,

ersetze das Sleep mal durch Application.ProcessMessages, das sollte funktionieren

Arne
andras Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 460

Win XP, Win Vista Home Premium, Ubuntu Dapper Drake
Delphi 2005 Pers
BeitragVerfasst: Do 27.10.05 21:42 
hab ich vorher gehabt. man kann zwar sagn dass es geordneter ablief aber trotzdem gings nicht richtig.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 27.10.05 23:13 
Moin!

user profile iconandras hat folgendes geschrieben:
wenn man aber alle sleep-anweisungen weglässt, hört das prog manchmal in der mittd auf oder drückt keine tasten oder lässt teile aus,... kurz, bei jedem mal kompilieren ists anders. WARUM??

Ich nehme mal an, du willst ein anderes Programm "fernsteuern". Da du quasi "künstlich" Ereignisse erzeugst, musst du der anderen Applikation auch die Gelegenheit geben, diese zu verarbeiten. Du kannst programmtechnisch die Ereignisse viel schneller erzeugen, als das andere Programm sie verarbeiten kann. Deshalb klappt´s mit dem Sleep(). Application.ProcessMessages() stellt ja praktisch nur eine kurze Verzögerung dar (und ist damit praktisch ein bischen wie Sleep()), aber eben doch nicht ganz so "lange", und deshalb klappt´s damit zwar besser, aber eben nicht gut.

cu
Narses
andras Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 460

Win XP, Win Vista Home Premium, Ubuntu Dapper Drake
Delphi 2005 Pers
BeitragVerfasst: Fr 28.10.05 07:51 
ok, danke!