I want to remap the keyboard layout/language switching to Win+Space, I tried it with:

LWin & Space::Send, ^+

But it doesn't seem to work, I would want it to send a Ctrl+Shift sequence so that I can switch between keyboard layouts with Win+Space.

How can I make this work?

  • 1
    Windows 10 has this by default now. Dec 8 '16 at 7:19
  • And boy do I wish I could turn it off. Oct 3 '17 at 16:19

Win+Space switch works fine on my win7-x64:

; 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)

w := DllCall("GetForegroundWindow")
pid := DllCall("GetWindowThreadProcessId", "UInt", w, "Ptr", 0)
l := DllCall("GetKeyboardLayout", "UInt", pid)
if (l = en) 
    PostMessage 0x50, 0, %ru%,, A
PostMessage 0x50, 0, %en%,, A

more details: http://www.autohotkey.com/board/topic/70019-keyboard-layout-switcher-for-many-layouts/

  • Just a tip: Please use "Str", "00000C00" for the default english layout. Works like a charm! If only I could now disable ALT+SHIFT shortcut so only WIN+SPACE changes it... Mar 29 '17 at 3:45

Are you sure this is Ctrl+Shift? On my system it is Alt+Shift. anyway, use this command:

LWin & Space::Send, {Alt Down}{Shift}{Alt up}

Replace Alt for Ctrl if your system indeed uses the Ctrl+Shift combination.


@Andrei Pak's script has the following limitations:

  1. Doesn't work in FileOpen dialog (and some other windows)
  2. Doesn't work in console windows
  3. 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.

  • 1
    This doesn't seem to be a complete, self-contained answer to the question. Can you elaborate?
    – fixer1234
    Feb 17 '17 at 21:09
  • OK then, if you say so.
    – stealzy
    May 15 '17 at 18:13
  • This is a much better solution. Feb 6 '18 at 9:10

You can easely (by changing first two lines to:

$~#Space up::LangSwitch(2)

) modify wOxxOm's Keyboard layout switcher for using Win+Space instead of right control. And it will work no matter which hotkeys are set up for switching layout in Windows (default is Alt+Shift, I'm using Ctrl+Shift).

Because of non-ahk-native switching (script uses WinAPI), whole script is rather bulky, so I didn't paste it inline. In case of autohotkey.com inaccessibility, here it is: http://pastebin.com/ygm3f6sp

(again, all credits go to wOxxOm, source script is there: http://www.autohotkey.com/board/topic/24666-keyboard-layout-switcher/)

P.S. That script is quite old, and has hardcoded byte-offsets, so I'm not sure if it will work with 64-bit Autohotkey.exe or in 64-bit Windows. I only have 32-bit at hand.


Your script is:

Sleep 500
Send, {CTRL}

then install puntoswitcher and set change language on control press. thats all

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.