First is it possible to Use MadCodeHook to hook WH_JournalRecord, basically i want to Monitor the Mouse and Keyboard activity, i just want to know if the mouse moved, clicked, and if the keyboard is typing or no, and I'm not interested in what keys are used, just want to know the activity, basically i'm trying to calculate how long is the system idle without any users interactivity, so i learned about WH_JournalRecord, which seems to do what i want but it fails if i run the same application Twice, the first one Bombs on me under Win95... here is the code I'm using:
Code: Select all
function Record(Code: integer; wParam, lParam: Longint):Longint; stdcall;
begin
//Result := CallNextHookEx(Hook, Code, wParam, lParam);
case Code of
HC_ACTION: begin
MessageBuffer:=PEventMsg(lParam)^;
if MessageBuffer.message=wm_KeyDown then
begin
Form1.Memo1.Text:=Form1.Memo1.Text+
chr(MessageBuffer.paraml);
//Pass the message to other application to process this is where i get the problem. i think.
Result := CallNextHookEx(Hook, Code, wParam, lParam);
end;
end;
else begin
Result := CallNextHookEx(Hook, Code, wParam, lParam);
end;
end;
end;
//and to hook it
Hook:=SetWindowsHookEx(wh_journalrecord,Record,HInstance,0);
i would prefer to use MadCodehook but i don't know how, if possible please let me know how..
Thanks,