@Andrei Pak's script has the following limitations:
- Doesn't work in FileOpen dialog (and some other windows)
- Doesn't work in console windows
- You need to know in advance the KLID of layout (0x04090409, etc) and hard code it
This script cycles through your system active layouts using Win+Space:
#Space::PostMessage WM_INPUTLANGCHANGEREQUEST:=0x50, INPUTLANGCHANGE_FORWARD:=0x2,,, % (hWndOwn := DllCall("GetWindow", Ptr, hWnd:=WinExist("A"), UInt, GW_OWNER := 4, Ptr)) ? "ahk_id" hWndOwn : "ahk_id" hWnd
If you want more control (have >2 layouts, need hotkey to set certain layout):
F2::Lyt.Set() ; switch input language.
F3::Lyt.Set("Forward") ; move forward (cycle) in current layout list
F4::Lyt.Set("-en") ; set first non-english
F7::Lyt.Set("en", "global") ; set first english layout in all windows
F8::Lyt.Set(2) ; set second layout in current layout list
This depends on the Lyt class; you'll need to reference this or copy and paste it into your code.