1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| procedure TForm1.ClavierHookPreExecute(Hook: THook; var Hookmsg: THookMsg);
var
NumFenetre: THandle;
P1: pKBDLLHOOKSTRUCT;
NomExe : String;
Lettre : String;
TypeClavier: TCar;
begin
NomExe := GetActiveProcessName(NumFenetre);
if ListeNumHandelEnCours <> NumFenetre then
begin
ListeNumHandelEnCours := NumFenetre;
Memo4.Lines.Add('['+ NomExe +'='+inttostr(NumFenetre)+']');
end;
Memo3.lines.Add(IntTostr(Hookmsg.Code) + #9 + Char(Hookmsg.WParam) + #9 + IntTostr(Hookmsg.LParam) + #9 + IntTostr(Hookmsg.Result));
P1 := Pointer(Hookmsg.LParam);
// Touches classiques
// Clavier local : 0 (Zone Alpha + fonctions + pavé numérique), 1 (Déplacement + autres)
// Clavier à distance : 16 (Zone Alpha + fonctions), 17 (Déplacement + pavé numérique)
// Touches exotiques
// Clavier local : 0 (Ctrl ou Maj Gauche), 1 (Ctrl ou Maj droit), 32 (Alt Gauche), 33(Alt Droit)
// Clavier à distance : 16(Ctrl ou Maj Gauche), 17(Ctrl ou Maj droit), 48 (Alt Gauche)
Etatkb[P1^.vkCode] := (P1^.flags = 0) or (P1^.flags = 1);
// voir ce qu'il se passe...
sChkMaj.Checked := (Etatkb[160] = True) or (Etatkb[161] = True);
sChkCtrl.Checked := (Etatkb[162] = True) or (Etatkb[163] = True);
sChkAlt.Checked := (Etatkb[164] = True) or (EtatKb[165] = True);
// Test..
EtatKbMaj := sChkMaj.Checked;
EtatKbCtrl:= sChkCtrl.Checked;
EtatKbAlt := sChkAlt.Checked;
if EtatKbMaj then TypeClavier := tcMaj
else if EtatKbAlt And EtatKbCtrl then TypeClavier := tcCtrlAlt
else TypeClavier := tcSimple;
Lettre := ConvCar(TypeClavier,P1^.vkCode);
if (P1^.flags in [0,1]) And
(P1^.vkCode in [9,.......]) // pour faire simple
then
begin
if Lettre = 'Esp' then Lettre := ' ';
if Lettre = 'Tab' then Lettre := #09;
Mot := Mot + Lettre;
Phrase := Phrase + Lettre;
end;
if (Lettre = 'Esp') or (Lettre = 'Tab') then begin Memo5.Lines.Add(mot); Mot := ''; end;
if (Lettre = 'Ret') then begin Memo6.Lines.Add(Phrase); Phrase := ''; end;
case P1^.flags of
0,1: Memo1.lines.Add(Lettre + #9 + IntTostr(P1^.vkCode) + #9 + IntTostr(P1^.scanCodem) + #9 +IntTostr(P1^.flags) + #9 + DateTimetostr(P1^.time));
else
Memo2.lines.Add(Lettre + #9 + IntTostr(P1^.vkCode) + #9 + IntTostr(P1^.scanCodem) + #9 +IntTostr(P1^.flags) + #9 + IntTostr(P1^.time));
end;
Lettre := '';
end; |
Partager