I have a C# application that needs to set the Windows language bar to english or at least back to the default setting. I know I can set the InputLanguage of my own application but I need to set the input language for Windows in general. This can be done manually using the language bar, but I need a way to do it programmatically. Is there a way to do this?
Asked
Active
Viewed 1,218 times
3 Answers
1
I ended up doing this:
Process[] apps=Process.GetProcesses();
foreach (Process p in apps)
{
if (p.MainWindowHandle.ToInt32()>0)
{
NativeWin32.SetForegroundWindow(p.MainWindowHandle.ToInt32());
//send control shift 2 to switch the language bar back to english.
System.Windows.Forms.SendKeys.SendWait("^+(2)");
p.Dispose();
}
}
0
I haven't done this since Windows XP was in it's childhood, so you may want to check if the language support is still based on the same principles. It is all Win32, so they need to be imported for C#.
First, read on MSDN the pages about keyboard input: http://msdn.microsoft.com/en-us/library/ms645530%28VS.85%29.aspx
GetKeyboardLayoutList tells you what layout are installed LoadKeyboardLayout loads a new input locale identifer. ActivateKeyboardLayout sets the current language

Madalina Dragomir
- 441
- 5
- 7
0
A much better approach to this is this:
//change input language to English
InputLanguage currentLang = InputLanguage.CurrentInputLanguage;
InputLanguage newLang = InputLanguage.FromCulture(System.Globalization.CultureInfo.GetCultureInfo("en-US"));
if (newLang == null)
{
MessageBox.Show("The Upload Project function requires the En-US keyboard installed.", "Missing keyboard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
else
{
InputLanguage.CurrentInputLanguage = newLang;
}
See full post on this: Language Bar change language in c# .NET