Sounds like we need C++/Win32 Finding all keyboard input languages?.
Found some example code in python kiwi:
import ctypes def GetLocaleInfo(value): s = ctypes.create_string_buffer("\000" * 255) ctypes.windll.kernel32.GetLocaleInfoA(0, value, s, 255) return str(s.value)
But that doesn't return a value for the layout list items...
It is all a bit confusing: why are the HKL and KLID of the keyboard different?
Here's another method which could be useful for locales:
def get_locale_language(): #apparently this can be different from the system locale try: langid = windll.kernel32.GetUserDefaultUILanguage() #@UndefinedVariable import locale lang = locale.windows_locale[langid] log("default ui language=%s", lang) return lang except Exception as e: log("failed to query current language: %s", e) return None
Found this useful example: NVDA's languageHandler.py.
And eventually figured out that this gives me what I want:
[locale.windows_locale.get(x & 0xffff) for x in win32api.GetKeyboardLayoutList()]
(bar any issues with HKL / KLID... as per above)
Which gave me on my test system:
['en_GB', 'en_US', 'fr_FR']
See also #1172.
Seems to be a problem with the 64-bit builds (#1413)
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1062