When I was a kid, most computers here in Brazil were using US QWERTY keyboards, and with some help from this nice teacher (on my MS-DOS 5.0) I taught myself typing on that keyboard layout.
One day, someone who should probably be a strong nationalist (or maybe a lobbyist, or maybe just someone suffering from NIH syndrome) invented the Brazilian Portuguese Keyboard and all retailers and companies started using that new standard. I resisted for many years, and remained buying myself only QWERTY keyboards, until I finally gave up and embraced the Brazilian keyboard, since it was getting harder to buy a QWERTY keyboard in Brazil.
The problem is that although we have created our own power plug standard, our own digital TV standard, our own TV middleware and even our own analog color TV standard in the 70s, we still have communication and interaction with other countries who follow other standards.
(If you don’t know Brazil, I must explain that all those standards are NOT about nationalism, patriotism or about Not-Invented-Here syndrome - it’s all about spending lots of public funds so that our politicians can divert huge amounts of money into their own pockets)
But jokes aside (no, the 3 standards were not a joke), sometimes we use Laptops that were purchased abroad (that don’t have our keyboard layout), and we share servers that are hosted or used by people in other countries. That keyboard mismatch usually happens when you are using some keyboard to control a computer which is also controlled by people with different keyboards.
Windows allows you to set-up multiple languages and multiple keyboards for each language, and you can also toggle keyboards/languages with a hotkey (default alt+shift). The problem is that if you type as fast as Mavis taught me to, probably you should frequently toggle keyboards by mistake as I do.
To solve that, I decided that I would disable the hotkey for toggling keyboards, and more than that, I decided to create a Powershell script that would completely remove one keyboard/language and configure another one.
The script below (just save as .ps1
extension) will toggle (uninstalling and reinstalling the other) between Portuguese Brazil ABNT2 keyboard (10416) and US Qwerty (409), but always keeping English language (409).
# This scripts toggles keyboards between "Keyboard Portuguese Brazil ABNT2" and "US Qwerty"
# based on https://technet.microsoft.com/en-us/library/hh852168.aspx
# and https://github.com/fdcastel/setup-fdcastel/blob/master/Setup-First.ps1
$currentLangAndKeyboard = (Get-WinUserLanguageList).InputMethodTips
if ($currentLangAndKeyboard -eq "0409:00000409")
{
$langList = New-WinUserLanguageList en-US
$langList[0].InputMethodTips.Clear()
$langList[0].InputMethodTips.Add('0409:00010416') # English (United States) - Keyboard Portuguese Brazil ABNT2
Set-WinUserLanguageList $langList
}
Else
{
$langList = New-WinUserLanguageList en-US
$langList[0].InputMethodTips.Clear()
$langList[0].InputMethodTips.Add('0409:00000409') # English (United States) - US Qwerty
Set-WinUserLanguageList $langList
}
# If you want to have two languages (or keyboards) at same time, just .Add() both, but disable toggle language hotkey - http://answers.microsoft.com/en-us/windows/forum/windows_xp-desktop/how-can-disable-switch-between-different-input/dba24e17-ad93-46e9-9775-baf097d550ee?auth=1
# $HKCUKeyboardLayoutToggle = 'HKCU:\Keyboard Layout\Toggle\'
# Set-ItemProperty -Path $HKCUKeyboardLayoutToggle -Name 'Language Hotkey' -Value 3
# Set-ItemProperty -Path $HKCUKeyboardLayoutToggle -Name 'Layout Hotkey' -Value 3
# Set-ItemProperty -Path $HKCUKeyboardLayoutToggle -Name 'Hotkey' -Value 3
As I said, I wanted to have only one language at a time to avoid the language hotkey, but later I realized that I could have just disabled that annoying hotkey. If you want to just disable the hotkey, just uncomment the final block in the script, which will add some keys to your registry. And if you want to use a powershell script to configure multiple keyboards (simultaneously), just call InputMethodTips.Add
for each language/keyboard you want to add.