Hello!
Little unimportant info about me:
I think i can program in c# in a quite good way,but
I would like to make my programs useful also for people who hasn't got .NET framework installed.
So i started to learn c and to rewrite my c# programs in c.
I'm writing a program ,and i have some problem with the global hotkeys.
I've been searching the WWW for a solution for ~ 12 hours now ,and i still couldn't get it to work, so that's why i decided to post here.
I'd like to Initalize a low level keyboard hook with the usage of SetWindowsHookEx(...) function, react to a keypress with the help of LowLevelKeyboardProc(...) function, finally un-initalize it with the UnhookWindowsHookEx(...) function.
I read that it is possible without using a dll file since it's low level, and i would be glad to do that.
Here is my code:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
LRESULT CALLBACK LowLevelKeyboardProc(
int nCode,
WPARAM wParam,
LPARAM lParam
);
HHOOK s;
int main()
{
//Initalize the hook
s = SetWindowsHookEx(WH_KEYBOARD_LL,LowLevelKeyboardProc,NULL,GetCurrentThreadId());
getchar();
// un-initalize the hook
UnhookWindowsHookEx(s);
return 0;
}
LRESULT CALLBACK LowLevelKeyboardProc(/* this should run when a key is hit on the keyboard*/
int nCode,
WPARAM wParam,
LPARAM lParam
)
{
printf("...");// just to let me know that the LowLevelKeyboardProc's been used
}
Please help me out if you can.
Andrew