C # - Automatically switch between two different IMEs in the same keyboard layout

I made a request to enter Chinese pinyin and hanzi into the database. This means that the operator has to constantly switch between "Pinyinput" and "sogou input" with ctrl + shift. Is there a way to make the IME change automatically when a text field is selected? I mean, don't switch keyboard layout, just input method of the same keyboard layout

+2


source to share


1 answer


try this, i am not sure about the name of the languages, try to debug it and get the correct name if it didn't work.

public void ToPinyinput()
        {
                string CName= "";
                foreach(InputLanguage lang in InputLanguage.InstalledInputLanguages) 
                {
                        CName = lang.Culture.EnglishName.ToString();

                        if(CName.StartsWith("Pinyinput"))
                        {
                                InputLanguage.CurrentInputLanguage = lang;
                        }
                }

        }


public void Tosogou()
        {
                string CName= "";
                foreach(InputLanguage lang in InputLanguage.InstalledInputLanguages) 
                {
                        CName = lang.Culture.EnglishName.ToString();

                        if(CName.StartsWith("sogou"))
                        {
                                InputLanguage.CurrentInputLanguage = lang;
                        }
                }

        }

      



If that didn't work, you need to change the following line to the correct lang name:

CName.StartsWith("langName")

      

+5


source







All Articles