GetKeyboardLayout is not updated during a console session #105

Open
opened 2026-01-30 21:42:28 +00:00 by claunia · 8 comments
Owner

Originally created by @bitcrazed on GitHub (Feb 16, 2018).

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

Originally created by @bitcrazed on GitHub (Feb 16, 2018). _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_
claunia added the Product-ConhostIssue-BugArea-Server labels 2026-01-30 21:42:28 +00:00
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

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.

@bitcrazed commented on GitHub (Feb 16, 2018): _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.
Author
Owner

@bitcrazed commented on GitHub (Feb 16, 2018):

From @matial on August 16, 2017 18:44

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

@bitcrazed commented on GitHub (Feb 16, 2018): _From @matial on August 16, 2017 18:44_ @sunilmut - Yes it is a generic console API problem.
Author
Owner

@miniksa commented on GitHub (May 29, 2019):

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.

@miniksa commented on GitHub (May 29, 2019): `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.
Author
Owner

@alabuzhev commented on GitHub (Aug 21, 2019):

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?

@alabuzhev commented on GitHub (Aug 21, 2019): > 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?
Author
Owner

@AnrDaemon commented on GitHub (Jul 10, 2022):

Soon five years… any news?

@AnrDaemon commented on GitHub (Jul 10, 2022): Soon five years… any news?
Author
Owner

@ajm19826 commented on GitHub (Jan 25, 2026):

Soon 8 years... any news?

@ajm19826 commented on GitHub (Jan 25, 2026): Soon 8 years... any news?
Author
Owner

@lhecker commented on GitHub (Jan 26, 2026):

It would certainly help if a big company made a big issue about this, so we could work on this leisurely and officially. Since that's not the case, we have to secretly smuggle it into our roadmap and this feature depends on a lot of road to map, I can tell you that. If I'm not run over by a bus this year, there's a decent chance for this to be fixed.

@lhecker commented on GitHub (Jan 26, 2026): It would certainly help if a big company made a big issue about this, so we could work on this leisurely and officially. Since that's not the case, we have to secretly smuggle it into our roadmap and this feature depends on _a lot_ of road to map, I can tell you that. If I'm not run over by a bus this year, there's a decent chance for this to be fixed.
Author
Owner

@ajm19826 commented on GitHub (Jan 26, 2026):

Ok

@ajm19826 commented on GitHub (Jan 26, 2026): Ok
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#105