Autor Beitrag
web
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: So 22.01.06 14:31 
Halo zusammen,...
Ich möcht nen Tastendruck von Str + V (also einfügen) simulieren, ... hab mir das so gedacht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
keybd_event(Ord(VK_CONTROL), 0, 0, 0); //Taste drücken
keybd_event(Ord('V'), 0, 0, 0); //Taste drücken
keybd_event(Ord(VK_CONTROL), 0, KEYEVENTF_KEYUP, 0); //loslassen
keybd_event(Ord('V'), 0, KEYEVENTF_KEYUP, 0); //loslassen


abder das funktionnier net,... vll kann mir jemand weiterhelfen wie das funktioniert.

Mfg :D
web Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 23.01.06 21:44 
push!
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 23.01.06 23:45 
Hallo,
das Ord kannst Du weglassen bei Ord(VK_CONTROL), denn es bewirkt nichts.
ausblenden Delphi-Quelltext
1:
2:
showmessage(IntToStr(Ord(VK_CONTROL)));// = 17
showmessage(IntToStr(VK_CONTROL));     // auch 17

Die Ursache des Fehlverhaltens wird einen anderen Grund haben.
Ich vermute das die gesendeten Tasten nicht dort ankommen wo Du sie haben willst.
Wenn Du den Code z.B. über einen Button ausführst, hat der Button den Focus,
und der kann eben mit Strg + V nichts anfangen.
So wird es funktionieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.ButtonClick(Sender: TObject);
begin
  Memo.SetFocus;
  keybd_event(VK_CONTROL, 0, 0 , 0);
  keybd_event(ord('V'), 0, 0, 0);
  keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
  keybd_event(ord('V'), 0, KEYEVENTF_KEYUP, 0);
end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )