I am using Hindi Indic Input 3 Language Pack for Hindi language. I need to provide multiple layout options for this language but when I check the installed language types it shows same Layout Id for all the layouts within this language pack. My objective is to allow users to switch between Mangal - CBI and Mangal - GAIL input from my WinForms application. Below is the code:
void ChangeCulture(string culture)
{
original = InputLanguage.CurrentInputLanguage;
var _culture = System.Globalization.CultureInfo.GetCultureInfo(culture);
var _language = InputLanguage.FromCulture(_culture);
if (InputLanguage.InstalledInputLanguages.IndexOf(_language) >= 0)
InputLanguage.CurrentInputLanguage = _language;
else
InputLanguage.CurrentInputLanguage = InputLanguage.DefaultInputLanguage;
}
I also used this native method for changing the keyboard layout using the layout id. But the problem is the layout id is same for all Hindi Indic Input 3 layout types .
[DllImport("user32.dll")]
private static extern IntPtr LoadKeyboardLayout(string pwszKLID, uint Flags);
LoadKeyboardLayout("hi-IN", 0xf0c00439);
I am unable to find any documentation on this language pack. Below is how it is selected from language bar. I need to select these two GAIL and CBI types from C# code. Please help.
Looks like you need to check an input locale identifier
(formerly called the keyboard layout, HKL) instead of InputLanguage. That's why your language stays the same (Hindi) when you have different layouts. You don't need the pack docs because installed 'language' is a part of the system.
OS Windows has a wider definition for 'InputLanguage' than just a 'keyboard layout'. It has ALL input channels, including 'speech-to-text', an Input Method Editor (IME). When the keyboard layout sets, it sets InputLanguage.CurrentInputLanguage
also.
So, yes, user32.dll
is the right way to call Window's C++ functions:
HKL GetKeyboardLayout(
[in] DWORD idThread
);
HKL ActivateKeyboardLayout(
[in] HKL hkl,
[in] UINT Flags
);
Just try other functions from this DLL. Such as GetKeyboardLayout
(get current layout for a thread), GetKeyboardLayoutList
(get all system layouts), ActivateKeyboardLayout
(set HKL as active).
Please, check the gist below from https://github.com/vurdalakov to play with layouts, not languages: https://gist.github.com/vurdalakov/9cea795e82109fdacb7062dcb122b42e
Hope, this will help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.