Thank you for the scripts.
Two issues while I'm here:
1. The loop in first script should recurse subkeys. On my 98SE system,
Preload has 4 subkeys called
1,
2,
3 and
4 respectively. Following line works:
loop HKEY_CURRENT_USER, Keyboard Layout\Preload,0,1
2. What about IMEs, how to retrieve additional languages/layouts? I have the Japanese IME installed (for Office XP) and
JP becomes available when opening an app from the Office suite. Strangely enough,
JP is also available when Character Map is open and focused. But it's not listed anywhere by either of the two scripts above. Food for thought...
Slightly modified script #1:
Code:
; This routine enumerates all keyboards which are installed on the system
; and returns the ID, the long and abbreviated name of the language
loop HKEY_CURRENT_USER, Keyboard Layout\Preload,0,1
{
RegRead Locale
locale := "0x" locale
VarSetCapacity(name, 128, 32) ; Set capacity new to clean up the buffer
Lang := DllCall("GetLocaleInfoA"
,Uint, Locale
,Uint, 2 ; &H2 'localized name of language
,Str, name
,UInt, 128)
lname := name
Lang := DllCall("GetLocaleInfoA"
,Uint, Locale
,Uint, 3 ; &H2 'Abbreviates name of language
,Str, name
,UInt, 128)
msgbox Locale code:`t%locale%`nLong name:`t%lname%`nShort name:`t%name%
}
[Later edit]Here's second script modified for a more elegant string retrieval and automatic display of the default locale in the dropdown; this was only tested in Win98SE so please check if it works correctly on your system(s):
Code:
; This routine enumerates all available languages on a system
; and stores them in a drop down list
Gui, Add, DropDownList, x10 y10 w250 r10 Sort vLanguages
EnumAddress := RegisterCallback("EnumerateLanguagesProc", Fast)
RegRead, def, HKEY_CURRENT_USER, Control Panel\International, Locale
StringRight, def, def, 4
Long := DllCall("EnumSystemLocalesA"
,Uint, EnumAddress
,Uint, 1)
Gui, Show
return
EnumerateLanguagesProc(lang)
{
global def
VarSetCapacity(loc, 4, 0)
DllCall("crtdll\strcpy", Str, loc, UInt, lang+4, cdecl)
locale := "0x" loc
VarSetCapacity(name, 128, 32) ; Set capacity new to clean up the buffer
Lang := DllCall("GetLocaleInfoA"
,Uint, Locale
,Uint, 2 ; &H2 'localized name of language
,Str, name
,UInt, 128)
locale := locale " " name
Lang := DllCall("GetLocaleInfoA"
,Uint, Locale
,Uint, 3 ; &H2 'Abbreviated name of language
,Str, name
,UInt, 128)
setdef := (def=loc) ? "||" : ""
locale := locale " " name setdef
GUIControl,,Languages, %locale%
return True
}
GuiClose:
ExitApp