Thema: Delphi KeyEvents manipulieren

Einzelnen Beitrag anzeigen

Savar

Registriert seit: 30. Mai 2004
Ort: Nalbach
43 Beiträge
 
Delphi 7 Enterprise
 
#1

KeyEvents manipulieren

  Alt 24. Mär 2006, 13:20
Ich möchte KeyEvents abfangen, verändern und weitersenden. Geht das überhaupt?
Ich nehmen an, dass ich dazu einen KeyboardHook wie diesen benötige:
Delphi-Quellcode:
library KeyboardHook;

uses
  Windows,
  Messages;

var
  HookHandle: Cardinal = 0;
  WindowHandle: Cardinal = 0;

function KeyboardHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
  Result := CallNextHookEx(HookHandle, nCode, wParam, lParam);
  case nCode < 0 of
    true: exit;
    false:
      begin
        //ANWEISUNGEN
      end;
  end;
end;

function InstallHook(Hwnd: Cardinal): Boolean; stdcall;
begin
  Result := False;
  if HookHandle = 0 then begin
    HookHandle := SetWindowsHookEx(WH_KEYBOARD, @KeyboardHookProc, HInstance, 0);
    WindowHandle := Hwnd;
    Result := TRUE;
  end;
end;

function UninstallHook: Boolean; stdcall;
begin
  Result := UnhookWindowsHookEx(HookHandle);
  HookHandle := 0;
end;

exports
  InstallHook,
  UninstallHook;
end.
Mit welchen Anweisungen kann ich das erreichen?
"Every day I have to add another name to the list of people that piss me off." Calvin
  Mit Zitat antworten Zitat