Windows Hacks

From Admin-SIG

Windows and Cygwin tricks useful to OSS enthusiasts.

Swap left-control and caps-lock

As an Emacs user, I really need to swap left-control with caps-lock. The pinky strech for control which is commonly used under emacs and many shells (like some modes of tcsh and bash) can cause serious repetitive motion injuries.

I am constantly searching for the little registry hack to do this, so I'll repeat it here.

In the registry editor, find the entry in the heirarchy:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout

This will modify the Keyboard layout for the current user. There is also a Keyboard Layouts key (notice the plural form) under the Control key, but that key should not be modified.

In the Keyboard Layout key, the Scancode Map value must be added. Do this by right clicking on Keyboard Layout and add a binary value. This should show as a REG_BINARY type entry. Name this value Scancode Map and enter the following value:

00 00 00 00   00 00 00 00
03 00 00 00   1d 00 3a 00
3a 00 1d 00   00 00 00 00

The first two 32-bit words are a header, all zeros. The next word says that there are 3 words of data in this entry, including the required null terminator. The next word says to remap key 1d (left shift) to 3a (caps-lock). The word after that says to remap key 3a to 1d.

3a is caps-lock
1d is left-shift

It appears that these operations need to end in a null terminator word. Hence the all zero word after these two remappings.

One could assume that more remapings could be done with more keycodes. There is a MicroSoft document somewhere that lists them, I'm sure. Just add 1 to the third word for every remapping you want to do, and add the appropriate remapping word to the list.

Elevated Privalages

Programs can be opened with elevated privileges. This can be handy for doing things like editing system files, which are not accessable to user accounts under Vista, even those with Administrator privelage. Access a program, like Notepad from the Start->All Programs->Accessories menu. Right click on the program, and select open as Administrator. This privalaged instance of Notepad can edit system files like .../drivers/etc/hosts. This can also be done for a command prompt, i think.