Shortcut to change keyboard hanging Anki Desktop up

Leaning thai I need to switch keyboard all the time for adding new cards.
Set up keyboard shortcuts in Windows 11 which are working fine everywhere except in Anki.
I have set Ctrl+1 = Danish, Ctrl+2 = Thai.
If I manually change the keyboard to thai and press Ctrl+1 it switch back to danish as expected. If I then press Ctrl+2 to change to thai, Anki stops responding.
Tried other setup for the shortcuts, but Anki stops every time no matter how I set i up.

Anki 2.1.49; Windows 10
I was literally going to post an issue with changing keyboard language when I saw someone posted just 20 minutes earlier…wow. So with me I had Alt+Shift+6 for foreign language and Alt+Shift+7 for English. Anki freezes up and I have to shut it down and restart. In addition, I had written an AHK script that could toggle the languages back and forth with the PAUSE button on the keyboard. This also crashes. It works outside of Anki. Seeing the previous post it sounds like just changing the language with a keyboard shortcut crashes it – I can click on the language bar and change it but I cannot use a keyboard shortcut unless I navigate away from Anki.

Well, I did not fix the problem but I found a work around. I used AutoHotKey script (can either compile to exe or just run the .ahk) to detect if Anki is active; if it is then I set focus to the desktop (it doesn’t minimize or change windows), ran the language toggle shortcut then shifted the focus back to Anki. If Anki is not active then I just run the language toggle shortcut (I assigned mine to the keyboard’s PAUSE key).

Pause::
IfWinActive ahk_exe anki.exe
{
  WinActivate, ahk_class Progman  ;<!-- Shift focus to desktop -->
  Sleep 200
  PostMessage, 0x50, 2, 0,, A     ;<!-- 0x50 is WM_INPUTLANGCHANGEREQUEST-->
  Sleep 200
  WinActivate, ahk_exe anki.exe   ;<!-- Shift focus back to Anki -->
}
else
{
  Sleep 100
  PostMessage, 0x50, 2, 0,, A     ;<!-- 0x50 is WM_INPUTLANGCHANGEREQUEST-->
}
return
;<!-- https://www.autohotkey.com/ -->

As I note both of you are using Windows, I really like using the default keyboard shortcut to switch keyboards since Windows 10, Win-Space. Unlike Ctrl-1 or Shift-Alt-whatever, it is more or less guaranteed not to conflict with any application keyboard shortcut. I have no experience with Thai keyboards though, and I know sometimes there is a need to switch between different keyboards within the same language, which could make it more complicated.

I do want to mention at one point I accidentally installed it the “Windows 7 way” where it shows EN/UR for the language codes instead of ENG/ار – even though I was on Windows 10. (See screenshot below.) I was somehow able to reinstall it to get the correct behavior. When it is installed the “Windows 10 way,” I think that is when the keyboard switch works across all applications. I remember in Windows 7, I had to switch it for each application. Maybe some people like it that way, I don’t know. Thanks for letting my ramble, this was going to keep me up at night, haha.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.