C # Change Current IME

Source: Internet
Author: User

1 to traverse all the input methods in the system, you can use the following program fragment:

foreach (InputLanguage lang in inputlanguage.installedinputlanguages) {
This.textBox1.Text + = "\r\nname>" +lang. Layoutname+ "\r\nculture>" +lang. Culture.name + "\ r \ n";

}

After you get all the input methods in the system, you can select specific input languages and input methods through culture and name.

2) switch to Simplified Chinese input Method
if (InputLanguage.DefaultInputLanguage.LayoutName.IndexOf ("keyboard") ==-1 && InputLanguage.DefaultInputLanguage.Culture.Name.Equals ("ZH-CN"))
{
Inputlanguage.currentinputlanguage= Inputlanguage.defaultinputlanguage;
}
Else
{
foreach (InputLanguage lang in inputlanguage.installedinputlanguages)
{
if (lang). Culture.Name.Equals ("ZH-CN") && lang. Layoutname.indexof ("keyboard") ==-1)
{
Inputlanguage.currentinputlanguage=lang;
Break
}
}
}
In this program, first of all, the system default input method to judge, if the default input method culture is ZH-CN, and input method name does not contain "keyboard" words, the default input method is a simplified Chinese input method, and is not "Chinese (Simplified)-US Keyboard", then the system default input method as the current input method.


If the above conditions are not met, all the input methods installed in the system are traversed, the first type of culture encountered when traversing is ZH-CN and the input method name does not contain the word "keyboard" as the current input method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.