问题
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