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

自古美人都是妖i 提交于 2019-12-11 03:28:13

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/1496756/c-sharp-automatically-switch-between-two-different-ime-in-the-same-keyboard-la

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!