I see that SetWindowsHookEx with WH_KEYBOARD and WH_MOUSE parameters can get
and control all keyboard and mouse message for the application or system.
It's work fine for application but no for system. My hook function is in a
DLL, and main form in a delphi project.
The comjplete instruction is
"MouseHook:=setWindowsHookEx(WH_MOUSE,@HookCode,0,0);"
Is it correct?
Alex.
The complete instruction is
"MouseHook:=setWindowsHookEx(WH_MOUSE,@HookCode,0,0);"
Is it correct?
>>
Yes,...and no
The function call itself is correct but...
<quote>
Creating a Windows systems hook requires special handling
under Win32, since the dll must be mapped (on the fly) into
the process space of every application that receives keystrokes.
<end quote>
To get the rest of this interresting story and a sample from
Joe C.Hecht goto www.deja.com search page and do a
PowerSearch for "Global keyboard hooks" in the same forum
as your now in (so b.p.d.winapi).
- Pieter
> I need to delete/control all keyboard and mouse action in my application.
>
> I see that SetWindowsHookEx with WH_KEYBOARD and WH_MOUSE parameters can
get
> and control all keyboard and mouse message for the application or system.
>
> It's work fine for application but no for system.
Here is a system wide keyboard and mouse hook example:
http://home.sol.no/~t-kvine/hook.zip
--
Regards
Torjei Kvinen
> Here is a system wide keyboard and mouse hook example:
> http://home.sol.no/~t-kvine/hook.zip
>
I am trying to study this example and it seams to work fine. My question is,
into the hooked procedure, is there a parameter for reading which button is
pressed? ... or the only way is to see the KeyState of VK_* you want?
Thanks
Daniel
> I am trying to study this example and it seams to work fine. My question
is,
> into the hooked procedure, is there a parameter for reading which button
is
> pressed? ... or the only way is to see the KeyState of VK_* you want?
Keyboard hook:
wParam specifies the virtual-key code.
case wParam of
VK_RETURN:
begin
end;
ord('A'):
begin
end;
VK_F1:
begin
end;
end;
Mouse hook:
wParam specifies the mouse message.
case wParam of
WM_LBUTTONDOWN:
begin
end;
WM_LBUTTONUP:
begin
end;
end;
--
Regards
Torjei Kvinen