如何确定当前输入语言? [英] How to determine the current input language?

查看:115
本文介绍了如何确定当前输入语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我屏幕键盘上设计的,

我需要确定哪些语言被用户和语言,他在其他线程现在使用的,集

I need to determine which language been set by the user and which language he is using now in the other threads,

即我需要知道在任务栏切换语言选择的语言:

i.e. I need to know the language selected in the taskbar language switcher:

PS当前区域性返回屏幕上的键盘应用程序所使用的语言,这是不是我期待的。

P.S. current culture returns the language used in the on screen keyboard application, which is not the case I am looking for..

推荐答案

的情况下解决办法是获取前台窗口的键盘布局,然后将其应用到屏幕上的键盘,并且在平时的方式。

The solution was to get the Keyboard Layout for the foreground window, and then apply it to the on screen keyboard, and check for the language in the usual ways..

            IntPtr fore = GetForegroundWindow();
            uint tpid = GetWindowThreadProcessId(fore, IntPtr.Zero);
            IntPtr hKL = GetKeyboardLayout(tpid);
            hKL = (IntPtr)(hKL.ToInt32() & 0x0000FFFF);
            InputLanguageManager m = InputLanguageManager.Current;
            m.CurrentInputLanguage = new System.Globalization.CultureInfo(hKL.ToInt32());
            //IntPtr i = LoadKeyboardLayout(hKL.ToString(), 1);

            InputLanguage = InputLanguageManager.Current.CurrentInputLanguage.ToString();

这篇关于如何确定当前输入语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆