_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_
_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?
Most helpful comment
There's an undocumented functiton
GetConsoleKeyboardLayoutNameWin 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?