Is it possible to set the Windows language bar to English or can I return to the default from the C # application

I have a C # application that should install the Windows language bar in English, or at least return to the default setting. I know that I can install 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 this programmatically. Is there any way to do this?

+3
source share
3 answers

I ended up with 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
source

, Windows XP , , . Win32, #.

MSDN : http://msdn.microsoft.com/en-us/library/ms645530%28VS.85%29.aspx

GetKeyboardLayoutList , LoadKeyboardLayout . ActivateKeyboardLayout

0

:

//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;
}

: #.NET

0

Source: https://habr.com/ru/post/1728481/


All Articles