0

The following snippet prints the key pressed. But it doesn't tell me if the i printed an alphabet in capital letters.It doesn't detect the caps lock when i press it,doesn't detect the shift key or any other key like the function keys etc. How do i do that ?

  wchar_t buff[10];
  BYTE keyState[256] = {0};
  KBDLLHOOKSTRUCT * kbhook = (KBDLLHOOKSTRUCT *) lParam;
  int result = ToUnicodeEx(   kbhook->vkCode,
                              kbhook->scanCode,
                              keyState,
                              buff,
                              10,
                              0,
                              NULL);


 wcout << result << endl;
program-o-steve
  • 2,630
  • 15
  • 48
  • 67
  • Have you checked the state of `keyState`? [toUnicdeEx docs](http://msdn.microsoft.com/en-us/library/windows/desktop/ms646322%28v=vs.85%29.aspx) specifically keyState variable. – RedX May 29 '12 at 11:50
  • 2
    That's because you pass a fake keyState instead of what you get from GetKeyboardState(). You are also ignoring my warning about the keyboard state being a process local property. http://stackoverflow.com/a/10719138/17034 – Hans Passant May 29 '12 at 13:11

0 Answers0