I got this idea a long time ago when i saw an app do this for a game.
i want to catch certain keystrokes. Something like /s myCommand. I had ppl msg me and mess me up through msn so my first command would be something like killmsn. I looked up the resource on msdn and got this far. This doesnt work, why doesnt it? is it BC of sleep? how else should i do this, note i dont have a window and i want this to be a console app. my KeyboardProc is NEVER called
#include <windows.h>
#include <stdio.h>
HHOOK hook;
LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam)
{
printf("%c", wParam);
return CallNextHookEx(hook, code, wParam, lParam);
}
int main()
{
hook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, GetModuleHandle(0), 0);
Sleep(10000);
UnhookWindowsHookEx(hook);
return 0;
}