Mikulas Dite
Mikulas Dite

Reputation: 7941

What key was pressed? Keyboard hooks

I'm using low level hooks, but I can't determine what key was pressed. Values are the same for every single key. Is here something I'm doing wrong?

Hook method

void hook() {

    /** this part is probably not important since I use global WH_KEYBOARD_LL, is that right? */
    HWND hwnd = FindWindow(NULL, "Vertices.exe");
    HINSTANCE instance = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);
    /** end part */

    SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, instance /** or NULL ? */, NULL);
}

Callback definition (I do have content in the app)

LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);

Values given with any key pressed

nCode:0 | wParam:0x100 | lParam:0x18fe14

just the wParam changes to 0x101 on key up (0x100 on key down)

Upvotes: 1

Views: 1074

Answers (1)

tenfour
tenfour

Reputation: 36896

KBDLLHOOKSTRUCT *kbdStruct = (KBDLLHOOKSTRUCT*)lParam;

:)

Upvotes: 3

Related Questions