Question

I did an application to enter chinese pinyin and hanzi in a database. That means that the operator have to switch constantly between "Pinyinput" and "sogou input" with ctrl+shift There is a way to make the IME change automaticall when a textbox is selected? I mean, not switch the keyboard layout, just the input method of the same keyboard layout

Was it helpful?

Solution

try this, I'm not sure about the name of the languages, try to debug it and get the right 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 it didn't work, you need to change the following line to the correct lang name:

CName.StartsWith("langName")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top