19 July 2011

Visual Studio randomly changes keyboard layout to US


I have been fighting with visual studio sometimes changing the keyboard layout from my Danish keyboard layout to US keyboard. All my internet search results on the topic suggested shortcuts being pressed, but I have disabled the language bar shortcuts and removed the US keyboard from my profile as the first thing I did when I logged on. I have also disabled all ease of access shortcuts.

Visual Studio is running in the Administrator context. This seems to be the root of the issue and I have now taken on the bigger guns for fixing this. I have gone into the registry and removed the US keyboard layout (409) from all the internal users also.

The registry (regedit.exe) contains keyboard layout information for all the native users of a windows installation and they still have the US keyboard registered. Windows SID S-1-5-18 / S-1-5-19 / S-1-5-20 and .DEFAULT, default being “All Users”.

Removing all references to the 00000409 keyboard under the following registry nodes and leaving only the one keyboard layout you wish to use fixes the bug. You can not change keyboard layout if you only have one. After the mentioned change and a reboot I have not had the problem again, Nice and simple.

HKEY_USERS\.DEFAULT\Keyboard Layout\Preload
HKEY_USERS\S-1-5-18\Keyboard Layout\Preload
HKEY_USERS\S-1-5-19\Keyboard Layout\Preload
HKEY_USERS\S-1-5-20\Keyboard Layout\Preload


Ps. Do not make changes in your registry unless you understand the possible consequences, and remember that backup is your friend.

No comments: