Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
Switch between multiple keyboard types within a language in C#

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.

enter image description here

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!