CaseSensitive Keyboard Hook

  • Thread starter Thread starter EA512
  • Start date Start date
E

EA512

Guest
Hi,

i made a programm. it displays the entered keys in a console window.

But all letters are in "caps lock"! How can i prevent that ?

eg. if i enter:
aBcDeFg

it displays:
ABCDEFG

Code:
__declspec(dllexport) LRESULT CALLBACK KeyEvent (int nCode,WPARAM wParam,LPARAM lParam)
{
    if  ((nCode == HC_ACTION) && ((wParam == WM_SYSKEYDOWN) || (wParam == WM_KEYDOWN)))
    {
        KBDLLHOOKSTRUCT hooked =
            *((KBDLLHOOKSTRUCT*)lParam);

        DWORD dwMsg = 1;
        dwMsg += hooked.scanCode << 16;
        dwMsg += hooked.flags << 24;

        char key[16];
        GetKeyNameText(dwMsg,key,15);

        std::cout << key;
    }
    return CallNextHookEx(hKeyHook,nCode,wParam,lParam);
}

Continue reading...
 
Back
Top