简体   繁体   中英

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

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

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM