hook i cos wiecej

0

to jest wziete z FAQ ale jak tu dopisac jakis warunek ktory reagowalby na wcisniecie klawiszy Shift,alt, F1-F12?

Oto kod ukazujący jak założyc funkcję przechwytująca na klawiaturę. W interface:

var MainHook : HHOOK;

function KeyHook(Code: Integer; wParam : WPARAM; lParam : LPARAM): Longint; stdcall;

A w Implementation:

function KeyHook(Code: Integer; wParam : WPARAM; lParam : LPARAM): Longint; stdcall;
var
Buffer: TEventMsg;
begin
result := 0 ;
Buffer := PEventMsg(lParam)^;
if Buffer.message = wm_KeyDown then
Form1.Memo1.Text := Form1.Memo1.Text + chr(Buffer.paraml);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
MainHook := SetWindowsHookEx(wh_JournalRecord, KeyHook, HInstance, 0);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
UnhookWindowsHookEx(MainHook);
end;

0

VK_F1 - VK_F12
Z Shiftem i Altem jest gorzej. Trzeba sprawdzić stan klawiszy. W FAQ jest (GetKeysState czy jakoś tak).

0

Może w ten sposób:

function KeyHook(Code: Integer; wParam : WPARAM; lParam : LPARAM): Longint; stdcall; 
var 
Buffer: TEventMsg; 
begin 
result := 0 ; 
Buffer := PEventMsg(lParam)^; 
if Buffer.message = wm_KeyDown then
if chr(Buffer.paraml) = #xx then Form1.Memo1.Text :=  Form1.Memo1.Text + '<SHIFT>' else Form1.Memo1.Text := Form1.Memo1.Text + chr(Buffer.paraml); 
end; 

gdzie #xx to albo numer SHIFTa albo ALTa

Powinno działać u mnie w ten sposób działa :-8 ...

1 użytkowników online, w tym zalogowanych: 0, gości: 1