Terminal: GetKeyboardLayout is not updated during a console session

Created on 16 Feb 2018  路  4Comments  路  Source: microsoft/terminal

_From @matial on August 13, 2017 21:0_

  • Your Windows build number: version 10.0.14393

  • Calling GetKeyboardLayout(0) periodically within a console application returns the handle of the keyboard layout active when starting the console. If the keyboard layout is changed while the console app is running, subsequent calls to GetKeyboardLayout do not reflect the new active layout.

  • What's wrong / what should be happening instead: GetKeyboardLayout should return the handle of the last activated keyboard layout.

_Copied from original issue: Microsoft/WSL#2418_

Area-Server Issue-Bug Product-Conhost

Most helpful comment

not specifically a console thing

There's an undocumented functiton GetConsoleKeyboardLayoutNameW in kernel32.dll, available at least since Windows 2000.
Despite being undocumented, it worked as expected until Windows 10.
And it still works as expected in legacy console mode.
In default mode, however, it now returns false and sets the last error to 16385 :(

If it's too hard to implement GetKeyboardLayout properly, can at least GetConsoleKeyboardLayoutNameW be fixed please? (undocumented == no guarantees, I know, but still).
Or maybe knowing how it works can help fixing GetKeyboardLayout?

All 4 comments

_From @sunilmut on August 16, 2017 16:41_

@matial - Thanks for your post. Is this a WSL/bash on Windows specific issue? Looks like a concern with the generic console API.

_From @matial on August 16, 2017 18:44_

@sunilmut - Yes it is a generic console API problem.

GetKeyboardLayout is a user32 thing... not specifically a console thing. We might need to hand this off to a different team via an internal issue.

not specifically a console thing

There's an undocumented functiton GetConsoleKeyboardLayoutNameW in kernel32.dll, available at least since Windows 2000.
Despite being undocumented, it worked as expected until Windows 10.
And it still works as expected in legacy console mode.
In default mode, however, it now returns false and sets the last error to 16385 :(

If it's too hard to implement GetKeyboardLayout properly, can at least GetConsoleKeyboardLayoutNameW be fixed please? (undocumented == no guarantees, I know, but still).
Or maybe knowing how it works can help fixing GetKeyboardLayout?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghvanderweg picture ghvanderweg  路  3Comments

NickITGuy picture NickITGuy  路  3Comments

alabuzhev picture alabuzhev  路  3Comments

waf picture waf  路  3Comments

TayYuanGeng picture TayYuanGeng  路  3Comments