1

I have buy this keyboard http://www.mobilitylab.eu/mini-design-touch-silver.html of 107 touch, and I want a keypad to put it on my left hand. but when we activate the numlock of the keypad, it activates the numlock on the keyboard. So we have 456- instead of uiop. I have found this program but it don't work on a 64 bits OS. http://www.bellamyjc.org/fr/systeme.html#knumlock.

So i want to do my own program with C++, but it don't work fine, the hook is allright (WH_GETMESSAGE) but i don't understand how we can change the keycode and how we can find if it's a key of the keypad or the keybord ?

Here this is my code where i try to change the message :

//-----------------Keyboard Hook Callback---------------//
Hookmsg_API LRESULT CALLBACK Hookmsg(int ncode,WPARAM wparam,LPARAM lparam){
    //if(ncode>=0) //
    if(ncode<0)
        return CallNextHookEx(hook,ncode,wparam,lparam);
    MSG *msg;
    msg=(MSG *)lparam;
    WORD newVK,oldVK;
    WORD newSC,oldSC;

    if(ncode==HC_ACTION)
    {
        if((msg->message == WM_KEYUP))//Check whether key was pressed(not released).)
        { 
            oldVK=msg->wParam;
            oldSC=SCANCODE(msg->lParam);
            bool extendkey=false;
            if(((HIWORD(msg->wParam) & 0x0100) == 0x0100))
            {
                extendkey=true;
            }
            if(!extendkey)
            {
                bool modif=true;
                switch(oldVK)//wparam
                {
                    case VK_INSERT: newVK=VK_NUMPAD0; break;
                    case VK_END: newVK=VK_NUMPAD1; break;
                    case VK_DOWN: newVK=VK_NUMPAD2; break;
                    case VK_NEXT: newVK=VK_NUMPAD3; break;
                    case VK_LEFT: newVK=VK_NUMPAD4; break;
                    case VK_CLEAR: newVK=VK_NUMPAD5; break;
                    case VK_RIGHT: newVK=VK_NUMPAD6; break;
                    case VK_HOME: newVK=VK_NUMPAD7; break;
                    case VK_UP: newVK=VK_NUMPAD8; break;
                    case VK_PRIOR: newVK=VK_NUMPAD9; break;
                    case VK_DELETE: newVK=VK_DECIMAL; break;
                    default: modif=false;
                }
                if(modif==true)
                {

                    msg->wParam = VK_NUMPAD0;
                    UINT newSC=MapVirtualKey(VK_NUMPAD0,MAPVK_VK_TO_VSC);
                    msg->lParam &= 0xFF00;
                    msg->lParam += (newSC << 16 );
                    //MessageBox( NULL, TEXT("OK"), TEXT("Error!"), MB_OK);
                }
            }

        }
    }
    return ( CallNextHookEx(hook,ncode,wparam,lparam) );//pass control to next hook in the hook chain.
}
genpfault
  • 51,148
  • 11
  • 85
  • 139
Delirium6
  • 45
  • 7

2 Answers2

0

cant understand u...
u have 2 keyboards?
if yes, try to use Raw Input (raw data from USB HID device)
http://msdn.microsoft.com/en-us/library/windows/desktop/ms645543(v=vs.85).aspx

Lparam and wparam are not visible for other applications.

befzz
  • 1,232
  • 13
  • 11
0

Keyboard input is much more than just windows messages. Modifying the messages will work in some cases, but is a vastly incomplete solution. You also need to consider driver state, GetKeyboardState, and others.

If you want to remap keys on your keyboard, you can create a new keyboard layout and assign it to a locale.

If keyboard layouts don't satisfy your needs, you will need to write a keyboard device driver.

If you only need this functionality in a specific application (not system globally), then you might be able to get lucky and only modify windows messages.

tenfour
  • 36,141
  • 15
  • 83
  • 142