Windows – Multiple input languages, switch between two

inputinput-languageswindows

How could I have three or more input languages active (namely English/Russian/Chinese), but cycle with Alt+Shift only between two of them (English/Russian)?

Punto Switcher handles this task only with custom shortcuts like Caps Lock or right Ctrl.

Best Answer

I solved this problem using AutoHotKey.

Set up 3 languages, a hotkey for switching between them and another hotkey for switching to the language you want to skip. I had English, Russian and Japanese and wanted to skip Japanese so I assigned Ctrl+Shift+0 to switch to JP.

I already had an AutoHotKey script that allowed me to switch between all the 3 languages using Caps. It looked like this:

CapsLock::Send, {Alt Down}{Shift Down}{Shift Up}{Alt Up}

The idea is to switch the language automatically once you switched to the language you want to skip. It's 0x0411 for Japanese. Paste yours in the if clause in the script below, save it and run it.

Here is the list of language ids, find yours in the first column.

The script only works for switching between languages using CapsLock but you can adapt it to Alt+Shift switch. Probably just by replacing "CapsLock" with "{Alt Down}{Shift Down}{Shift Up}{Alt Up}".

CapsLock::
Send, {Alt Down}{Shift Down}{Shift Up}{Alt Up}

if !LangID := GetKeyboardLanguage(WinActive("A"))
{
    MsgBox, % "GetKeyboardLayout function failed " ErrorLevel
    return
}

if (LangID = 0x0411)
    Send, {Alt Down}{Shift Down}{Shift Up}{Alt Up}
return

GetKeyboardLanguage(_hWnd=0)
{
    if !_hWnd
        ThreadId=0
    else
        if !ThreadId := DllCall("user32.dll\GetWindowThreadProcessId", "Ptr", _hWnd, "UInt", 0, "UInt")
            return false

    if !KBLayout := DllCall("user32.dll\GetKeyboardLayout", "UInt", ThreadId, "UInt")
        return false

    return KBLayout & 0xFFFF
}
Related Question