WinAPI LowLevel Keyboard Hooks

DLimited tanojoshu at googlemail.com
Thu Jul 19 04:45:33 PDT 2012


Hello everyone,

I had this great idea of writing a Program that intercepts all
keyboard presses and modifies them in certain cases.
I want to use it as some kind of global makro program to run in
the background and for example allow me to easily post unicode
smileys.

This is where the probelms begin.
If I understood the WinAPI doc correctly, I need to install a
LowLevel Keyboard Hook using SetWindowsHookEx().

Unfortunately there are two versions of this function,
SetWindowsHookExW and SetWindowsHookExA. What's the difference?

The function to get called is passed as a parameter, but
apparently it needs to be located in a .dll if using global hooks.


So I need to first load my .dll file using LoadLibraryA( ) or
LoadLibraryW( ), locate my function using GetProcAddress( ) and
then set the hook using SetWindowsHookExW (or *-A)).


Unfortunately for me, even the LoadLibrary function fails,
returning "Module could not be found". Now I'm 99% sure my .dll
is crap because this is the first time I ever wrote one, but it
DOES have a DllMain(), initializes the D Runtime and also has the
other function I want to install the hook for.

I'm hoping some bright minds here could help me out because
google didn't, and I'm out of my depth.
If you want me to, I'll post the source code, but I didn't want
this post to get too big, which still did, but anyway.


More information about the Digitalmars-d-learn mailing list