0

I've got three input languages on my Windows machine (Russian, English and French). However, I only use the French keyboard once in a blue moon. So I want the Alt + Shift combo to cycle between Russian and English, so French would only be available via the menus. Is that possible?

1
  • I've discovered a program called Keyla that seems to do exactly what I want. Feb 20, 2012 at 16:59

2 Answers 2

1

You can set the key combination for switching between languages or keyboard layouts in the Advanced Key Setting dialog box. To open the Advanced Key Setting dialog box, right-click the Language bar, and then click Settings. Under Preferences, click Key Settings.

Or look at control panel for language bar settings.

Source

5
  • Thanks, but you don't seem to have understood the question. I'm asking about the possibility to make that key combination NOT switch to some input languages. Giving French its own shortcut doesn't solve that. Feb 18, 2012 at 6:54
  • If French is chosen as input language, it will come to that keyboard shortcut cycle. That's what that shortcut is for. To remove it from shortcut, you have to remove French as input language.
    – Bibhas
    Feb 18, 2012 at 7:07
  • So there are no ways to remove it from the shortcut without removing it altogether? Feb 18, 2012 at 7:33
  • Shortcut is just a way to do a certain action quickly. In this case to change between the keyboard layouts you chose. So, No. If you do not use a layout, just remove it. You can then, once in a blue moon, add French again and use it. That's better than cycling through it everyday.
    – Bibhas
    Feb 18, 2012 at 9:45
  • I'm on Windows 10, and it doesn't work. Other people also experience this buggy behavior.
    – HeyJude
    May 25, 2020 at 11:00
0

You can use an AutoHotKey script for that.

The following script is an example of cycling between English US and Hebrew, while having 3 more available languages (Russian, Hindi Traditional and Hindi Phonetic). It works as follows:

  • When left alt+left shift are pressed, it waits for them to be released.
  • If they are released without an additional key press, only English and Hebrew are cycled (that's the closing else part).
  • In case any of the following are pressed: 1,2,3, then the keyboard layout would change to the specified language (Russian, Hindi Traditional, and Hindi Phonetic, respectively).

Here it is:

LAlt & LShift::waitAndSet()

waitAndSet() {
  KeyWait, LAlt
  KeyWait, LShift

  USA := 0x4090409
  HEB := 0x40d040d
  RUS := 0x4190419 
  HIN := 0x00000439
  HINPHON := 0x04090439

  if (A_PriorKey = "1") {
    setDefaultKeyboard(RUS)
  } 
  else if (A_PriorKey = "2") {
    setDefaultKeyboard(HIN)
  }
  else if (A_PriorKey = "3") {
    setDefaultKeyboard(HINPHON)
  }
  else {
    currentKeyboardLayout := getCurrentKeyboardLayout()
    setDefaultKeyboard(currentKeyboardLayout = USA ? HEB : USA)
 }
}
setDefaultKeyboard(hkl){
    SPI_SETDEFAULTINPUTLANG := 0x005A 
  , SPIF_SENDWININICHANGE := 2 
  , WM_INPUTLANGCHANGEREQUEST := 0x50
    VarSetCapacity(binaryhkl, 4, 0)
    NumPut(hkl, binaryhkl)
    DllCall("SystemParametersInfo", "uint", SPI_SETDEFAULTINPUTLANG, "uint", 0, "uptr", &binaryhkl, "uint", SPIF_SENDWININICHANGE)
    PostMessage WM_INPUTLANGCHANGEREQUEST, 0, % hkl, , A
}
getCurrentKeyboardLayout() {
  SetFormat, Integer, H
  WinGet, WinID,, A
  ThreadID:=DllCall("GetWindowThreadProcessId", "uint", WinID, "uint", 0)
  priorHKL :=DllCall("GetKeyboardLayout", "uint", ThreadID, "uint")
  Return priorHKL
}

Remarks:

  1. You mentioned keyla in the comments, but I tried it and it's very buggy and no longer maintained, plus you'd have to use Windows' Advanced Keyboard Settings (to add shortcuts for setting the non-cycled languages) which is also buggy.

  2. The original code for setDefaultKeyboard can be found here, but I made some changes to it (otherwise it didn't work).

  3. The HKL hardcoded values for the specified languages was retrieved by changing manually the layout to each language and running getCurrentKeyboardLayout each time. You can read this post for more context.

  4. There are cases where it won't work, though I can't find a consistent behavior.
    For example, for Hindi Traditional, getCurrentKeyboardLayout actually returns 0xf00c0439 (and not the value present in the code above), but using it doesn't work.
    As another example, for Russian Mnemonics keyboard, getCurrentKeyboardLayout returns 0xf0330419, and again, using this value doesn't work. In fact, if you've got both Russian and Russian Mnemonics layout on your machine, using 0x4190419 sometimes changes the layout to Russian, but sometimes to Russian Mnemonics, dependant on the previous language used! The "solution" is to remove one of them.

You must log in to answer this question.

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