Hi All,
I am trying to convert my application to multilingual application which will support all OS language.
Now for example if I change my keyboard layout from control panel to arabic my application should start working for arabic and for other langauge like spanish and so on.
So the idea is to get the keyboard layout in arabic langauge, get all keys text in that keyboard and use in my application.
I found lot of code but none of them is working.
http://www.codeproject.com/KB/winsdk/RightKeyboard.aspx
This seems bit promising but how can I change it according to my requirement. I got keyboard id now how can I get all keys text in that keyboard id.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Windows.Forms;
namespace HotKey
{
public static class CurrentCultureInfo
{
#region Fields & Properties
private static int lpdwProcessId;
private static InputLanguageCollection installedInputLanguages = InputLanguage.InstalledInputLanguages;
private static CultureInfo currentInputLanguage;
public static string InputLangTwoLetterISOLanguageName
{
get { return CurrentCultureInfo.currentInputLanguage.TwoLetterISOLanguageName; }
}
public static string InputLangThreeLetterWindowsLanguageName
{
get { return CurrentCultureInfo.currentInputLanguage.ThreeLetterWindowsLanguageName; }
}
public static string InputLangThreeLetterISOLanguageName
{
get { return CurrentCultureInfo.currentInputLanguage.ThreeLetterISOLanguageName; }
}
public static string InputLangNativeName
{
get { return CurrentCultureInfo.currentInputLanguage.NativeName; }
}
public static string InputLangName
{
get { return CurrentCultureInfo.currentInputLanguage.Name; }
}
public static int InputLangLCID
{
get { return CurrentCultureInfo.currentInputLanguage.LCID; }
}
public static int InputLangKeyboardLayoutId
{
get { return CurrentCultureInfo.currentInputLanguage.KeyboardLayoutId; }
}
public static string InputLangEnglishName
{
get { return CurrentCultureInfo.currentInputLanguage.EnglishName; }
}
public static string InputLangDisplayName
{
get { return CurrentCultureInfo.currentInputLanguage.DisplayName; }
}
#endregion
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern int GetWindowThreadProcessId(IntPtr handleWindow, out int lpdwProcessID);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetKeyboardLayout(int WindowsThreadProcessID);
public static int GetKeyboardLayoutIdAtTime()
{
IntPtr hWnd = GetForegroundWindow();
int WinThreadProcId = GetWindowThreadProcessId(hWnd, out lpdwProcessId);
IntPtr KeybLayout = GetKeyboardLayout(WinThreadProcId);
for (int i = 0; i < installedInputLanguages.Count; i++)
{
if (KeybLayout == installedInputLanguages[i].Handle) currentInputLanguage = installedInputLanguages[i].Culture;
}
return currentInputLanguage.KeyboardLayoutId;
}
}
}
How this tutorial code can work, its seems promising.
http://www.csharphelp.com/2007/01/keyboardlayout-and-language-selector/
Please help
Thanks a lot
[edit]Code block added, indentation added, "Ignore HTML..." option disabled, urgency deleted - OriginalGriff[/edit]