5

I have three languages on my system: English, Russian and Japanese. But I only want to be able to Alt+Shift between English and Russian. Is there a way to do it on Windows 10?

This question doesn't apply here, because it doesn't work on Windows 10.

5

3 Answers 3

3

Follow this steps:

  1. Install AutoHotkey.
  2. Create a text file and paste the following text:
; This scripts changes the functionality of Shift + Alt from "switch keyboard layout"
; to "change to previous layout".
; this is usefull when you have more than 2 keyboard layouts and want to switch between 
; only 2 of them.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

LAlt & LShift::send, #^{space down}{space up}
  1. Save and rename the file with .ahk extension (e.g. "Exclude Extra Keyboard Layouts.ahk")
  2. Double click to run the script. Now Alt+Shift should switch only between the first two keyboard layouts.

If you are satisfied you can compile the script (right click -> compile) to create the .exe file. then move the .exe or .ahk file to the start-up folder (open RUN and type "shell:startup" without quotes).

Extra Notes:

  • If you copy the .exe file you don't need AutoHotkey anymore so you can uninstall it.
  • If you copy the .ahk script file you must not uninstall AutoHotkey.
  • This post solves a somewhat similar problem, helped to come up with the idea.
0

I suggest probably slightly better approach with same autohotkey solution.

Instead of switching to previous layout (which might be the third), better to disable native Alt+Shift cycling hotkey and make way for own layout switching logic.

disable example

And use following script, maybe with desired adjustments:

#SingleInstance force
SendMode Input

; Cycled list of language ids
; refer to https://docs.microsoft.com/en-us/windows/win32/intl/language-identifiers
; and https://docs.microsoft.com/en-us/windows/win32/intl/language-identifier-constants-and-strings
; for finding out correct values
; in this case 0x409 means standard US English, and 0x419 means standard Russian
AltShiftLangs := [0x0409, 0x0419]

; 0x411 means japanese IME
CtrlAltLang := 0x0411

; This returns currently active language id
GetKeyboardLayout() {
  WinGet, WinID,, A
  ThreadID:=DllCall("GetWindowThreadProcessId", "UInt", WinID, "UInt", 0)
  return DllCall("GetKeyboardLayout", "UInt", ThreadID, "UInt") & 0xFFFF
}

; This sends request to change system language to lang argument
SetKeyboardLayout(lang) {
  PostMessage, 0x50,, lang,, A
}

; This returns 0-based index of Value in Arr
IndexOf(Arr, Value) {
  Loop % Arr.Length()
    if Arr[A_Index] == Value {
      return A_Index-1
    }
  return -1
}

; This sets language based on current system lanuage and next value by index in Arr
; If current language is not found, it sets system to first language from Arr
SetNextLanguage(Arr) {
  lang := GetKeyboardLayout()
  idx := IndexOf(Arr, lang)
  if (idx < 0) {
    SetKeyboardLayout(Arr[1])
    return
  }
  nextIdx := mod(idx+1, Arr.Length())
  next := Arr[nextIdx+1]
  SetKeyboardLayout(next)
}

; Alt+Shift hotkey - cycle between AltShiftLangs
LAlt & LShift::
SetNextLanguage(AltShiftLangs)
return

; Ctrl+Alt hotkey - switch directly to isolated CtrlAltLang
LCtrl & LAlt::
SetKeyboardLayout(CtrlAltLang)
return
0

I had a same problem and found a pretty simple way to solve it with reg editing wrote a guide with a help of chat gpt

It will remove chosen languge from shortcuts and language bar

How to Exclude a Language from Win+Space or Alt+Shift Shortcut in Windows

Note: Please exercise caution when editing the Windows Registry, as it can have system-wide effects. Always back up your registry or create a system restore point before making changes.

Step 1: Open Language Bar Options

  1. Press Win + I to open the Windows Settings.
  2. Click on "Time & Language."
  3. Select "Language" from the left-hand menu.
  4. Scroll down and click on "Advanced keyboard settings" under the "Related settings" section.
  5. Under "Language bar preferences," click on "Language bar options."
  6. In the "Text Services and Input Languages" window that appears, go to the "Advanced Key Settings" tab.

Step 2: Create a Special Shortcut for the Language

  1. Click on "Change Key Sequence."
  2. Choose a custom keyboard shortcut for switching to the language you want to exclude (e.g., German).
  3. Click "Apply" and then "OK" to save the changes.

Step 3: Open the Registry Editor

  1. Press Win + R to open the Run dialog.

  2. Type "regedit" and press Enter. This opens the Windows Registry Editor.

Step 4: Navigate to the Keyboard Layout Preload Key

In the Registry Editor, navigate to the following key:

HKEY_CURRENT_USER\Keyboard Layout\Preload

Step 5: Identify the Language Value

  1. In the right pane, you will see a list of language codes and values. Each value corresponds to a keyboard layout.

  2. Identify the value that corresponds to the language you want to exclude (e.g., "00000407" for German). It will have a numerical code associated with it.

Step 6: Remove the Language Value

  1. Right-click on the value that corresponds to the language you want to exclude.
  2. Select "Delete" from the context menu.
  3. Confirm the deletion if prompted.

Step 7: Close the Registry Editor Close the Registry Editor.

Note: This action will remove the language from the list of preload keyboard layouts, and it should no longer appear when you use the Win+Space or Alt+Shift shortcut to switch languages. You can still access the excluded language using the custom keyboard shortcut you created in Step 2 or by adding it back to the preload list in the Registry when needed.

Remember to be cautious when editing the Windows Registry, and make sure to back up your registry or create a system restore point before making changes

1
  • This does not work as expected for me. This removes the language from switch language cycle but the language hotkey combination does not work as well.
    – Boogier
    Dec 14, 2023 at 9:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .