Registriert seit: 31. Jan 2008
Ort: im schönen Salzburger Land
461 Beiträge
Delphi XE4 Professional
|
AW: Tastatur Hook
23. Jul 2010, 11:53
Ein "Lazarus"-Quelltext für Tastaturhook als DLL
HTH Erich
Delphi-Quellcode:
{$mode objfpc}{$H+}
{$IFDEF WINDOWS}{$R Programmname32.rc}{$ENDIF}
uses
Classes,
Windows,
ActiveX,
ShlObj,
Messages,
SysUtils;
var
HookHandle: Cardinal = 0;
AppHandle: HWND;
function KeyboardHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
Result := CallNextHookEx(HookHandle,
nCode,
wParam,
lParam);
if nCode = HC_NOREMOVE then Exit;
if ((lParam and (1 shl 30)) <> 0) then
begin
if wParam = VK_F4 then
begin
PostMessage(FindWindow( nil,' Fenstername von deinem Programm'), WM_USER + 8760, 300, 0);
end
else
begin
PostMessage(FindWindow( nil,' Fenstername von deinem Programm'), WM_USER + 8760,wParam,lParam);
end;
end;
end;
function StartHook32(ApplicationHandle: HWND): Boolean; stdcall;
begin
Result := False;
if HookHandle = 0 then
begin
HookHandle := SetWindowsHookEx(WH_KEYBOARD,
@KeyboardHookProc,
HInstance,
0);
AppHandle := ApplicationHandle;
Result := TRUE;
end;
end;
function StopHook32: Boolean; stdcall;
begin
Result := UnhookWindowsHookEx(HookHandle);
HookHandle := 0;
end;
exports
StartHook32,
StopHook32;
end.
Erich Wanker - for life:=1971 to lebensende do begin ..
|
|
Zitat
|