Get Keyboard layout

Discussion in 'Questions (Windows Mobile)' started by Byak@, May 26, 2009.

  1. Byak@

    Byak@ Active Member Licensed User

    i'm found interesting code for C#.how adapt it for basic?
    Code:
    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;
    }
    }
    }
     
  2. Cableguy

    Cableguy Expert Licensed User

    This seems to be a complete .cs file...
    Wich means that you could try to add it to a SharpDevelop Class project and compile it, if successfull, then you have a working dll...
    I may try it latter in the day, as I am now going out...
     
  3. Byak@

    Byak@ Active Member Licensed User

    Thanks Cableguy
    and do it without creating a lib in B4p isn't possible?
     
  4. Cableguy

    Cableguy Expert Licensed User

    I don't thing its possible as this seems to be a wraper of some "user32.dll" properties...
    Anyway here's the dll:

    PS:
    Please note that this is NOT a zip file, I only added the .zip to the dll, so only need to delete the ".zip" from the name
     

    Attached Files:

  5. Byak@

    Byak@ Active Member Licensed User

    i'm not found a "new" method =(
    Cableguy please correct it
     
  6. Byak@

    Byak@ Active Member Licensed User

    UP!
    Can anyone help with it?
     
  7. agraham

    agraham Expert Licensed User

    Here you are.
     

    Attached Files:

  8. Byak@

    Byak@ Active Member Licensed User

    Big thanks!it's work)
    what about do it for device? and please give source of this lib for embed
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice