2010-01-14 110 views

回答

0

我落得这样做:

Process[] apps=Process.GetProcesses(); 
foreach (Process p in apps) 
{ 
    if (p.MainWindowHandle.ToInt32()>0) 
    { 
     NativeWin32.SetForegroundWindow(p.MainWindowHandle.ToInt32()); 

     //send control shift 2 to switch the language bar back to english. 
     System.Windows.Forms.SendKeys.SendWait("^+(2)"); 

     p.Dispose(); 
    } 
} 
0

自从Windows XP在童年时代以来,我还没有这样做过,所以您可能想要检查语言支持是否仍然基于相同的原则。它都是Win32,因此需要为C#导入它们。

首先,在MSDN上关于键盘输入的页面阅读: http://msdn.microsoft.com/en-us/library/ms645530%28VS.85%29.aspx

GetKeyboardLayoutList告诉你什么布局安装 LoadKeyboardLayout加载新的输入法区域设置IDENTIFER。 ActivateKeyboardLayout设置当前语言

0

一个更好的这种做法是这样的:

//change input language to English 
InputLanguage currentLang = InputLanguage.CurrentInputLanguage; 
InputLanguage newLang = InputLanguage.FromCulture(System.Globalization.CultureInfo.GetCultureInfo("en-US")); 
if (newLang == null) 
{ 
    MessageBox.Show("The Upload Project function requires the En-US keyboard installed.", "Missing keyboard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 
    return; 
} 
else 
{ 
    InputLanguage.CurrentInputLanguage = newLang; 
} 

见本完整的文章:Language Bar change language in c# .NET