Skip to content

andresapitt/AutoRightKeyboard

Repository files navigation

AutoRightKeyboard

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.

How It Works

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.

Features

  • 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.txt for troubleshooting

Tray Menu

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

Building

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


Changelog

v2.0 — 2026-02-24

Performance Optimizations

  • Replaced BroadcastSystemMessage with ActivateKeyboardLayout — Direct API call for faster layout switching, with SendMessage to 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 GetKeyboardLayoutList to find the real system handle instead of constructing it manually

New Features

  • 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_DEVICECHANGE to 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 + Unicode SendInput

Bug Fixes

  • Fixed unclosable dialog — Added Skip button to layout selection; dialog no longer blocks indefinitely
  • Fixed virtual device override — Filters out Microsoft Keyboard RID\0 virtual device that was firing on every keypress and overriding real keyboard layout switches
  • Fixed duplicate device registrationLoadDeviceList now checks for duplicate device names before adding

Infrastructure

  • Retargeted to .NET Framework 4.7.2 (from 4.0)
  • Added P/Invoke declarations for ActivateKeyboardLayout, SendMessage, PostMessage, ToUnicodeEx, GetKeyboardState, SendInput, and related structs

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages