How to change input language in C # code?

I am writing a wpf application using C # (VS2010), and when my application starts, the input language is taken from the system input language, which is English.

I want my application to automatically change the input language without pressing ( Shift + Alt)

Can you tell me how to do this?

Another question, can I change the time zone on my system using my application?

+3
source share
3 answers

If you just want to change the input language for your application, see InputLanguage.CurrentInputLanguage

, SystemParametersInfo SPI_SETDEFAULTINPUTLANG.

TimeZoneInfo , SetTimeZoneInformation.

+6

, , Google , " wpf" ( ) WPF InputLanguageManager: http://msdn.microsoft.com/en-us/library/system.windows.input.inputlanguagemanager.aspx , InputLanguage. , .

+4

You should use this function:

public static void lang(string lge)
{
    System.Globalization.CultureInfo TypeOfLanguage = new System.Globalization.CultureInfo(lge);
    InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(TypeOfLanguage);
}

and when you call this function, the lge parameter should be the label of the desired language, for example, โ€œar-dzโ€ for Algerian Arabic or โ€œfr-frโ€ for French.

+2
source

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


All Articles