What key was pressed? Keyboard hooks

喜欢而已 提交于 2019-12-11 06:31:26

问题


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)


回答1:


KBDLLHOOKSTRUCT *kbdStruct = (KBDLLHOOKSTRUCT*)lParam;

:)



来源:https://stackoverflow.com/questions/3495337/what-key-was-pressed-keyboard-hooks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!