This script aims to fix that issue, allowing to switch between two layouts no matter how many of them you have enabled in Windows:
; This should be replaced by whatever your native language is. See ; http://msdn.microsoft.com/en-us/library/dd318693%28v=vs.85%29.aspx ; for the language identifiers list. ru := DllCall("LoadKeyboardLayout", "Str", "00000419", "Int", 1) en := DllCall("LoadKeyboardLayout", "Str", "00000409", "Int", 1) !Shift:: w := DllCall("GetForegroundWindow") pid := DllCall("GetWindowThreadProcessId", "UInt", w, "Ptr", 0) l := DllCall("GetKeyboardLayout", "UInt", pid) if (l = en) { PostMessage 0x50, 0, %ru%,, A } else { PostMessage 0x50, 0, %en%,, A }
Known problems:
[*:okyfdnxp]The code above works only if you press Alt first, then Shift. If you press Shift first then Alt, normal layout switching mechanism is used. If you don't like this behavior, it is quite easy to change it to work for Shift-Alt too.
[*:okyfdnxp]The layout is switched as soon as Shift is pressed. This is different from the way Windows handles it, when switching occurs when you release one of the keys, provided you didn't press anything else in-between. This could be annoying if you use some shortcuts like Alt+Shift+V somewhere. A workaround is to press Shift+Alt+V instead, but it requires some practice to get used to it.