Homepage of Eduardo Terol

You are here:  Home > Software > Keyboard-Remapper

Keyboard-Remapper

This is a tool to remap keys in the keyboard. But it can do lots more. You can associate a key or a combination of keys to :

  • A program
  • A menu to run other programs
  • Sleep / hibernate the computer
  • Write a string

One unique feature of this software is that if you have more than one keyboard or an additional keypad, you can remap the keys of the each keyboard independently. If you for instance have a keyboard lacking multimedia keys, you can just buy a numeric pad for 5€ and remap the keys of the numeric pad to emulate the multimedia keys.

To use the application just run the exe and a new icon will appear beside the clock:

Pressing onto the icon with the right key of the mouse brings you to the configuration dialog, where you can reprogram the keyboard:

 

When selecting a line, the keys programmed for this macro will highlight in the keyboard image.

With a double click on a macro you can edit it:

Technical details

There are tons of programs in internet able to remap the keys of your keyboard, many of them are free and are very good. What most of them lack is the ability to differentiate the keys coming from different devices. The only program I know able to do this is HIDMacros. Unfortunately this software works only with 32 bits and is closed source.

To differentiate the keystrokes from different devices one need to use the function RegisterRawInputDevices. With this function one can register a callback which gets called by each key pressed with information about the device. This function is able to inform the registered application about keystrokes, but it doesn't allow the calleé to prevent these keystrokes from being processed by other applications.

To remove keystrokes this application uses two types of hooks: WH_KEYBOARD and WH_KEYBOARD_LL. WH_KEYBOARD_LL (LL means low-level) is fairly easy to implement in C#. Only drawback, it gets called before the callback registered with RegisterRawInputDevices, which makes it useless for the purpose of replacing keystrokes.

WH_KEYBOARD on the other hand is called after the callback registered with RegisterRawInputDevices, but it is not that trivial to program. Unlike WH_KEYBOARD_LL, the hook must reside in a DLL which gets injected in every running application. Which means that every application has a copy of the dll in its address space. In 64-bit systems it means that 32-bit Dlls are needed for 32 bit applications and 64 bit dlls are needed for 64-bit applications. 

Other possibility is having a 64-bit dll which gets injected on each 64 bit application while 32 bit applications run the code in a stub in the one who set the hook in the first place. This is the approach taken by this software.

Lastly, some keys, which are not being redirected to the applications theirselves, won't trigger a WH_KEYBOARD event. This is the case for the toggle keys like Caps and Num locks (I am not sure whether there are more). For these keys I use WH_KEYBOARD_LL to be able to remap them.

If you want to compile the Hook DLL yourself you will need a 64bit compiler. I used the codeblocks IDE with the mingw64 compiler.

Download

Version v1.0 (14-08-2012)

Zipped binary

Win 64-bit 

Download

Source code

64-bit hook DLL

Download

Source code

GitHub
   
Requirements

.NET 4.0

64 Bit

 

Please use the forum to report problems, tell your opinion, etc.