0

I am trying to get the program to say what key the user has pressed using Windows hooks. So far I have been able to get the program to say some kinda message when they press a key but rn im trying to get it say what key they pressed but when I try to access the structure that has that data i get the error: "Expression must have a class type" and I have no idea how to fix it. I tried doing: struct -> vkCode but then I get the error: "expression must have pointer type" So i am at a loss as what to do, here is my code.

LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM keyState, LPARAM keyInfo) {//The function that is called when a key is pressed
LRESULT reValue = 0;//Initialize the return value

DWORD keyCode = keyInfo.vkCode;

if (keyState == WM_KEYDOWN) {
    MessageBox(hWnd, L"A key was pressed", L"Message", MB_OK);//Put this in message box if the key is down
}

if (nCode < 0) {
    reValue = CallNextHookEx(keyboardHook, nCode, keyState, keyInfo);
}


return reValue;

};

here is the line where the error is

DWORD keyCode = keyInfo.vkCode;
drescherjm
  • 10,365
  • 5
  • 44
  • 64
sharpchain
  • 355
  • 2
  • 7
  • 15

0 Answers0