Autor Beitrag
Ezekiel
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Sa 12.10.02 18:47 
hey.

ich möchte tastencodes an ein fenster senden.
ich weiss das die exe datei gestartet ist, ich kenne auch den fenster namen.
ich benutze delphi 7 und winxp.

ausblenden volle Höhe 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:
var
  mWnd : HWND;

procedure TForm1.FormCreate(Sender: TObject);
begin
id1:=GlobalAddAtom('Hotkey1');
RegisterHotKey(handle,id1,0,VK_Pause);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnRegisterHotKey(handle,id1);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(handle,id1);
end;

procedure TForm1.WMHotKey (var Msg : TWMHotKey);
var
  i: byte;
begin
if  msg.HotKey  = id1 then
begin
  if EXE_Running('notepad.exe',false) then
    begin
      mWnd := Findwindow(nil,pchar('Editor'));
      PostMessage(mWnd, WM_KEYDOWN, VK_NUMPAD0, 0);
    end
    else MessageDlg('notepad is not running.', mtInformation, [mbOk], 0);
end;
end;

end.


problem 1:
der system weite hotkey funzt nur wenn das eigene programm aktiv ist.
wenn ich die hotkey taste drücke während ich in notepad schreibe, passiert garnichts.

problem 2:
ich kann die keys an das programm senden, also an das fenster handle, aber nicht in das feld, beispielsweise das edit feld in notepad.

any sugegstions #1?

thx
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Sa 19.10.02 20:40 
Sorry, aber selbstverständlich funktioniert der Hotkey nur dann, wenn dein Programm läuft. Du könntest es höchstens permanent im Hintergrund laufen lassen.

Keystrokes kann man auch mit Keyb_Event() verschicken. Dabei passiert das gleiche, wie enn du auf deiner Tastatur eine Taste drückst, d.h. die Message wird an das aktive programm geschickt. Du könntest vor Keyb_Event() Notpad aktivieren. Villeicht hilft dir das.

- AP -