Windows – How to make the current keyboard layout more obvious in Windows 10

keyboardkeyboard-layoutlanguagewindowswindows 10

I speak both French and English, and I very often switch from one keyboard (French Canadian) to another (English US). When I write French emails, the French keyboard becomes necessary for accents (e.g. é, è, à, ç, etc.), while using Vim/writing code is much more practical with the US layout.

The problem is that very often, I start typing, realize I'm using the wrong keyboard layout, and then I have to go delete and re-type what I was doing. This is especially true for Vim, where I can quickly destroy a document in a few keystrokes.

Is there a way to make the current keyboard layout much more obvious than the small bottom-right corner indicator? Are there existing settings in Windows, or software I could install, that could help?

Examples of what I mean when I'm using a specific keyboard layout:

  • A colored screen border
  • A permanent overlay (modal, popup)
  • Changing the taskbar color
  • Etc.

Other suggestions that would help reduce lost time using the wrong keyboard layout are appreciated.

Best Answer

This is an alternative that works for me up to now; Using AutoHotkey, I dynamically switch to a preferred language for specific software (E.g. Vim uses en-CA, and Slack uses fr-CA).

This is not an answer to my specific question, but if it worked for me, it might work for other people too:

https://gist.github.com/christianrondeau/00d7cd5848f33e029f00ce2b6b935ab9

; How to use:
; 1. Install AuthotKey: https://www.autohotkey.com
; 2. Save this script in `My Documents`
; 3. Create a shortcut in the Startup folder (`Win`+`R`, `shell:startup`)
; 4. Change the configurations below
; 5. Start and test the script!

; Configuration

    ; Cultures can be fetched from here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx
    ; They must be set twice in the language ID;
    ;   en-US: 0x04090409
    ;   fr-CA: 0x0C0C0C0C

global DefaultLanguage := "fr-CA"
global DefaultLanguageIndentifier := "0x0C0C0C0C"
global SecondaryLanguage := "en-US"
global SecondaryLanguageIndentifier := "0x04090409"
global SecondaryLanguageWindowTitles := "VIM,Visual Studio"

; And the code itself (you should not have to change this)

Gui +LastFound 
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,Hwnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

ShellMessage( wParam,lParam )
{
 WinGetTitle, title, ahk_id %lParam%
; 4 is HSHELL_WINDOWACTIVATED, 32772 is HSHELL_RUDEAPPACTIVATED
 If (wParam=4 || wParam=32772) {
    If title contains %SecondaryLanguageWindowTitles%
        SetKeyboard( title, SecondaryLanguage )
    Else
        SetKeyboard( title, DefaultLanguage )
 }
}

SetKeyboard( title, culture )
{
    ; 0x50 is WM_INPUTLANGCHANGEREQUEST.
    Try
    {
        If (culture = SecondaryLanguage)
        {
            PostMessage, 0x50, 0, %SecondaryLanguageIndentifier%,, A
            ; To debug:
            ; ToolTip, Using secondary language %SecondaryLanguage%
            ; Sleep 1000
            ; ToolTip
        }
        Else If (culture = DefaultLanguage)
        {
            PostMessage, 0x50, 0, %DefaultLanguageIndentifier%,, A
            ; To debug:
            ; ToolTip, Using default language %DefaultLanguage%
            ; Sleep 1000
            ; ToolTip
        }
        Else
        {
            ; To debug:
            ; ToolTip, Unknown culture: %culture%
            ; Sleep 1000
            ; ToolTip
        }
    }
    Catch e
    {
        ToolTip, Could not switch to %culture%`n%e%
        Sleep 1000
        ToolTip
    }
}
Related Question