How to know which keyboard layout is currently active using cmd in Windows 7 32bit?

6,070

Edit: The below won't actually do what the OP requires as the values don't change when the keyboard is switched via the Language Bar shortcut, even though they do if you do it via the Control Panel. Leaving for completeness.

I cannot find any documented systeminfo or Powershell commands that may retrieve this information. I thought something like this may work, but alas none of the parameters for this or other cmdlets seem to be able to get hold of this setting.

powershell -Command "& {(Get-culture).keyboardlayoutid;}"

It seems Windows 8 may have added Powershell commands that do this, but in Windows 7 it does appear that you cannot detect changes made in this way.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

The following will return the current keyboards:

reg query "HKEY_CURRENT_USER\Keyboard Layout\Preload"

This will return a list of all installed keyboards, with the one currently in use as 1.

HKEY_CURRENT_USER\Keyboard Layout\Preload
    1    REG_SZ    00000809
    2    REG_SZ    00000407
    3    REG_SZ    00000c0a

For reference, the values returned are listed here: msdn.microsoft.com/en-gb/goglobal/bb895996.aspx

Share:
6,070

Related videos on Youtube

doctorate
Author by

doctorate

It cannot be about me, it is all about ONE, the Author of life, the Smitten Rock, the Prince of peace, His Name is Wonderful, the Holy One of Israel, the Good Shepherd, the Way, the Truth, and the Life. The King of kings and Lord of lords, God blessed forever, Jesus the Christ. Without Him you don't have anything but eternal torment (no annihilation) in Hell because of your sinful nature. Don't take your life for granted, everything you see is for a brief time and then will vanish. How come you care about everything except your very life that may stop at any moment? But that won't be the end, for there will be a righteous Judgment waiting for you after that according to the Bible, how horrible? So dear sinner, with all love even in LaTeX: is He your personal Savior? If not you are in utter danger, but I am glad to tell you that in Him there is hope as He never rejects a broken sinner, seriously troubled with his sins. Come to Him with all of your burdens, but you can ever trust Him Who is Mighty to Save. Repent, not relying on yourself but on His perfect and finished work on the Cross at Calvary, and believe in the gospel, even today, for the Kingdom of God (Jesus Christ) is at hand.

Updated on September 18, 2022

Comments

  • doctorate
    doctorate over 1 year

    Suppose I can switch between 3 keyboard layouts, English, German, and Spanish from the language bar of Windows 7 32bit. What command can be run from cmd to return the value of the current layout in use? My ultimate goal is to pass the returned value into an external editor (Emacs) so that it can change the font of the text based on the current keyboard layout. That is, if I write a sentence in English the font will be font1, if in German font2, and so on. But that will only work if I can get some returned value (whether number of country locale or string line english, german, and so on) from the command line of Windows.

  • doctorate
    doctorate over 9 years
    But I get the same output no matter to which layout I switch ALT + L SHIFT. Is it the same with you? can you post the output if you switch to other language.
  • Lunatik
    Lunatik over 9 years
    Ah, it seems the keyboard shortcut doesn't change this value.
  • doctorate
    doctorate over 9 years
    my intention is to change the input keyboard language by a shortcut key as one would normally do when entering text in a notepad to gain speed. Besides, changing keyboard layout from control panel doesn't seem to be relevant.
  • doctorate
    doctorate over 9 years
    Is there way to return a value of the current language as set by the shortcut Left Alt + Left Shift?
  • Lunatik
    Lunatik over 9 years
    Sorry, I've had a good dig about and it doesn't seem there's an easy way to get this status if it is changed via the keyboard shortcut. Perhaps someone with better Powershell knowledge can help.