Autor Beitrag
Yojinbo
Hält's aus hier
Beiträge: 9



BeitragVerfasst: So 01.02.04 21:14 
Hallo ich hab ein Programm geschrieben das an eine andere Anwendung tasten übergiebt
ich hab "Keybd_Event" verwendet. nur leider kann ich nur buchstaben übergeben. z.b der Punkt (.) geht nicht.
hier z.b das "K"

keybd_event(75,0,0,0);
mit dem punkt müsste es doch so gehen (macht es aber nicht.
keybd_event(46,0,0,0);

Hoffentlich kann mir jemand helfen.
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: So 01.02.04 21:30 
Hi,

Sollte eigentlich damit funktionieren:

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 SimulateKeyDown(Key: Byte);
begin
  keybd_event(Key, MapVirtualKey(Key, 0), 0, 0);
end;

procedure SimulateKeyUp(Key: Byte);
begin
  keybd_event(Key, MapVirtualKey(Key, 0), KEYEVENTF_KEYUP, 0);
end;

procedure PostSimpleKeyToKbd(KeyCode: Word);
begin
  if KeyCode and $100 <> 0 then SimulateKeyDown(VK_SHIFT);
  if KeyCode and $200 <> 0 then SimulateKeyDown(VK_CONTROL);
  if KeyCode and $400 <> 0 then SimulateKeyDown(VK_MENU);
  SimulateKeyDown(Lo(KeyCode));
  SimulateKeyUp(Lo(KeyCode));
  if KeyCode and $400 <> 0 then SimulateKeyUp(VK_MENU);
  if KeyCode and $200 <> 0 then SimulateKeyUp(VK_CONTROL);
  if KeyCode and $100 <> 0 then SimulateKeyUp(VK_SHIFT);
end;

procedure PostAltNumToKbd(Ch: Char);
var
  S: String;
  i: Integer;
  K: Byte;
begin
  S := Format('%4.4d', [ord(Ch)]);
  SimulateKeyDown(VK_MENU);
  for i := 1 to Length(S) do begin
    K := ord(S[i]) + VK_NUMPAD0 - ord('0');
    SimulateKeyDown(K);
    SimulateKeyUp(K);
  end;
  SimulateKeyUp(VK_MENU);
end;

procedure PostCharToKbd(Ch: Char);
var
  KeyCode: Word;
begin
  KeyCode := VkKeyScan(Ch);
  if KeyCode = $FFFF
  then PostAltNumToKbd(Ch)
  else PostSimpleKeyToKbd(KeyCode);
end;



Aufrufen:
ausblenden Delphi-Quelltext
1:
  PostCharToKbd('.');					
Yojinbo Threadstarter
Hält's aus hier
Beiträge: 9



BeitragVerfasst: So 01.02.04 21:50 
Vielen Dank! Das ist ech cool das man mir so schnell hilft!
Das bringt mich um einiges weiter!! Danke
Der-DeeJay
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: Fr 06.02.04 17:51 
HI

Ich hab auch soaws gesucht aber ich hab da noch ein Problem :[

wenn ich z.B. NumLock als Taste nehme kann ich sie nur Aktivieren aber nich dealtivieren

weis einer von euch wie das geht?????

MFG

Der DeeJay
Yojinbo Threadstarter
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Di 10.02.04 22:49 
Ich hätte auch noch was.
Und zwar:

Ich kann zwar jetzt Text senden. aber jetzt ist das Problem das ich an das Programm dan druck der "^" bzw "°"-Taste. Das Programm öffnet normalerweis dann die Console. Aber wenn ich die Taste sende dann passiert garnichts.

Hat jemand evtl. eine Idee wie ich das machen kann?
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Do 11.03.04 21:08 
Zitat:
wenn ich z.B. NumLock als Taste nehme kann ich sie nur Aktivieren aber nich dealtivieren

weis einer von euch wie das geht?????


Nimm diesen Code: www.swissdelphicente.../showcode.php?id=926


aber jetzt ist das Problem das ich an das Programm dan druck der "^" bzw "°"-Taste.

Für ^ musst du ein "^" senden und einen Space:
ausblenden Delphi-Quelltext
1:
2:
PostCharToKbd('^');
PostCharToKbd(' ');