Automatically switches keyboard layouts based on which physical keyboard you're using. Designed for multi-keyboard setups where each keyboard should use a different language/layout.
based on https://github.com/gmcouto/RightKeyboard but I added new features and rewrite of many components.
AutoRightKeyboard runs in the system tray and uses the Windows Raw Input API to detect which physical keyboard generated each keypress. When you switch between keyboards, it automatically changes the active keyboard layout.
- Automatic layout switching — Detects physical keyboard changes and switches layouts instantly
- Device memory — Remembers keyboard-to-layout mappings across sessions (
%LocalAppData%\RightKeyboard\config.txt) - Default layout — Set a default layout for unknown/new keyboards to avoid popups
- Hot-plug support — Detects keyboards plugged in after the app starts
- Instant Switch mode — Attempts to correct the first character typed after a keyboard switch (experimental)
- Device logging — Log file at
%LocalAppData%\RightKeyboard\device_log.txtfor troubleshooting
| Option | Description |
|---|---|
| Clear | Resets all keyboard mappings — you'll be prompted again on next keypress |
| Set Default Layout | Pick a layout to auto-assign to unknown keyboards (no popup) |
| Instant Switch | Toggle experimental character correction on keyboard switch |
| Open Log | Opens the device log file in Notepad |
| Exit | Closes the application |
Requires:
- .NET Framework 4.7.2 Developer Pack
- Visual Studio Build Tools 2022 (or full Visual Studio)
MSBuild RightKeyboard.csproj /p:Configuration=Release
Output: bin\Release\RightKeyboard.exe
- Replaced
BroadcastSystemMessagewithActivateKeyboardLayout— Direct API call for faster layout switching, withSendMessageto the foreground window for synchronous effect - Device caching — Skips redundant layout checks when typing on the same keyboard
- Struct-based
RAWINPUTHEADER— Converted from class to struct, eliminating per-keypress heap allocation - Proper system HKL lookup — Uses
GetKeyboardLayoutListto find the real system handle instead of constructing it manually
- Default layout auto-assignment — Set a default layout via tray menu; unknown keyboards get this layout automatically with no popup
- Hot-plug device support — Handles
WM_DEVICECHANGEto detect keyboards plugged in after startup - Device logging — Logs detected devices, layout switches, and device changes to
device_log.txt - Open Log menu item — Quick access to the log file from the tray menu
- Instant Switch mode (experimental) — Attempts to correct the first character after a keyboard switch using
ToUnicodeEx+ UnicodeSendInput
- Fixed unclosable dialog — Added Skip button to layout selection; dialog no longer blocks indefinitely
- Fixed virtual device override — Filters out
Microsoft Keyboard RID\0virtual device that was firing on every keypress and overriding real keyboard layout switches - Fixed duplicate device registration —
LoadDeviceListnow checks for duplicate device names before adding
- Retargeted to .NET Framework 4.7.2 (from 4.0)
- Added P/Invoke declarations for
ActivateKeyboardLayout,SendMessage,PostMessage,ToUnicodeEx,GetKeyboardState,SendInput, and related structs