Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to get active keyboard layout in command line?  (Read 21596 times)

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

    Topic Starter


    Hopeful

    Thanked: 2
    How to get active keyboard layout in command line?
    « on: April 19, 2020, 06:44:29 PM »
    Hi!

    I found over the net that in Windows 7 was possible in command line to get active keyboard layout.
    By this Registry reading:

    reg query "HKEY_CURRENT_USER\Keyboard Layout\Preload"

    It displays installed layouts (not languages) in system, active will contain number 1.
    I used it and tried - no change of value. For to be sure I was searching for ID list - yes, found, but I have own layouts created with KbdEdit. These cannot to have any common ID, so I think I need only one simple thing - read only active keyboard indication instead list with values without change - value I'll get I will take as important.

    How to fix it? Or exist other way?
    Thank you all.
    Miro

    Hackoo



      Hopeful
    • Thanked: 42
    • Experience: Expert
    • OS: Windows 10
    Re: How to get active keyboard layout in command line?
    « Reply #1 on: April 19, 2020, 11:28:26 PM »
    Hi  ;)
    You can find the language codes here
    May be those powershell commands can give you an idea   ???
    You can execute it by cmd like this :
    This command returns the language list for the current user account and the corresponding display name.
    Code: [Select]
    powershell -C Get-WinUserLanguageListThis command returns the list of currently enabled input methods as a TIP string.
    Code: [Select]
    Powershell -C (Get-WinUserLanguageList)[0].InputMethodTipsThis command returns the autonym property of the first item in the user language list.
    Code: [Select]
    Powershell -C (Get-WinUserLanguageList)[0].autonymDocumentation about Get-WinUserLanguageList
    « Last Edit: April 20, 2020, 12:23:37 AM by Hackoo »

    Hackoo



      Hopeful
    • Thanked: 42
    • Experience: Expert
    • OS: Windows 10
    Re: How to get active keyboard layout in command line?
    « Reply #2 on: April 20, 2020, 12:40:13 AM »
    You can make a batch file like this :
    Code: [Select]
    @echo off
    Title How to get active keyboard layout in command line ?
    @for /f  %%a in ('Powershell -C (Get-WinUserLanguageList^)[0].InputMethodTips') do Set "IMT=%%a"
    echo Active KeyBoard Code = %IMT%

    @for /f  %%b in ('Powershell -C (Get-WinUserLanguageList^)[0].autonym') do set "CurrentLang=%%b"
    echo Active KeyBoard Language = %CurrentLang%
    pause

    MIRKOSOFT

      Topic Starter


      Hopeful

      Thanked: 2
      Re: How to get active keyboard layout in command line?
      « Reply #3 on: April 21, 2020, 01:33:41 AM »
      Batch displays language but it looks inactive - I select other layout and no change.

      Miro