Autor Beitrag
Opa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Mo 13.02.06 17:52 
Wie kann man feststellen ob in einem fremden Prg eine Taste gedrückt wurde z.B. in WinWord

MFG
DarkHunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: Mo 13.02.06 18:25 
Du müsstest einen Hook auf den Tastendruck legen ;)
aber frag mich nicht wie xD

_________________
I believe that every human has a finite number of heart-beats. I don't intend to waste any of mine running around doing exercises.
- Neil Armstrong
Opa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Mi 15.02.06 00:24 
Ich habe schon eine ganze Weile probiert, und wenn ich das wüsste würde ich nicht fragen. Und im Netz habe ich auch nicht wirklich was gefunden das auf mein Problem anzuwenden ist.

MFG
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 15.02.06 00:49 
Dazu musst Du einen globalen Keyboard-Hook (in einer DLL) schreiben und diesen dann bei Windows als solchen registrieren. Beispiel-Sources gibt's u.a. hier im WinAPI-Forum.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Opa Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Do 16.02.06 23:41 
So habe ich es auch gelöst!
Zusammengefast mal den Code,- muss allerdings noch ein wenig ausgearbeitet werden.
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:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
library WinWordHookDLL;//in WinWordHookDLL.dpr 
uses
  Windows,Messages;
var
  MyHook   : HHOOK;
  MyHandle : HWND = 0;

const
 WM_HOOK_CLICK = WM_USER+100;

function GetHook(code: integer; HwParam: WPARAM; HlParam: LPARAM ): LRESULT; stdcall;
var
  MyWnd: HWND;
begin
  if Code = HC_ACTION then
  begin
    MyWnd := GetForegroundWindow();
    if   MyWnd =  MyHandle then SendMessage(MyHandle,WM_HOOK_CLICK,hwParam,hlParam);
      //postMessage(MyHandle),WM_HOOK_CLICK,hwParam,hlParam);
    result := CallNextHookEx(myHook,code,HwParam,HlParam);
  end else result := CallNextHookEx(myHook,code,HwParam,HlParam);
end;
//------------------------------------------------------------------------------
procedure WordHookDLLInit(HDLL: HINST; install:boolean;Handle:HWND); stdcall
begin
  if install = true then
  begin
    MyHandle := Handle;
    MyHook   := SetWindowsHookEx(WH_KEYBOARD,@GetHook,HDll,0);
  end else UnhookWindowsHookEx(MyHook)
end;
exports
  WordHookDLLInit index 1;
end.
//------Form-----------------
const
  WM_HOOK_CLICK  = WM_USER+100;
private
    F_HookDLL        : HINST;
    InitHookProc     : procedure (hDLL: HINST; install: boolean;H:HWND); stdcall;
  F_HookDLL := LoadLibrary('WinWordHookDLL.dll');
procedure WMHookClick (var Msg: TMessage); message WM_HOOK_CLICK ;//User message
//---------------------------
procedure TMain.FormShow(Sender: TObject);
begin
  if  F_HookDLL <> 0 then
  begin
    InitHookProc := GetProcAddress(F_HookDLL,'WordHookDLLInit');
    InitHookProc(F_HookDLL,true,Handle);
  end;
end;
procedure TMain.FormDestroy(Sender: TObject);
begin
  F_HookDLL := LoadLibrary('WinWordHookDLL.dll');
  if  F_HookDLL <> 0 then
  begin
    InitHookProc := GetProcAddress(F_HookDLL,'WordHookDLLInit');
    InitHookProc(F_HookDLL,true,Handle);
  end;
end;
//----------------------------
procedure TMain.WMHookClick (var Msg: TMessage);
begin
  try
   ShowMessage('Sendung Angekommen');
  except
  end;
end;


Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt