CapsLockIndicator icon indicating copy to clipboard operation
CapsLockIndicator copied to clipboard

Keyboard layout indicator

Open oleg-sgh opened this issue 3 years ago • 6 comments

Hello. Is it possible to add a keyboard layout indicator when enabling a layout other than the default one?

oleg-sgh avatar Dec 11 '21 16:12 oleg-sgh

Doesn't Windows already come with an input indicator?

jonaskohl avatar Dec 20 '21 07:12 jonaskohl

Doesn't Windows already come with an input indicator?

It is very small and not noticeable. It would be nice if there would be the same notification with a different layout. I use the on-screen notification mode when Num Lock, Caps Lock, and Scroll Lock are on.

oleg-sgh avatar Dec 20 '21 08:12 oleg-sgh

I have taken another look at it and implementing this seems to be a huge undertaking, as there is a) no managed function to retrieve the current keyboard layout, so p/invoking would be necessary and b) the keyboard layout is set on a per-thread basis, thus making it really difficult to retrieve the keyboard layout for any given process.

jonaskohl avatar Jan 10 '22 11:01 jonaskohl

I now have a homemade app on AutoHotkey. A narrow red stripe above the taskbar if a different layout. Maybe something will help.

Color1 := "0x0C0BC0", Color2 := "f00000",  x := 0, y := 718, w := 1400, h := 6
loop
{
  If (InputLayout() = "English")
  {
    Gui, +AlwaysOnTop -Caption +ToolWindow +LastFound
    Gui, Color, % Color2
    Gui, Show, x%x% y%y% w%w% h%h% NA
  }
  else
    Gui Destroy
    sleep, 50
}
InputLayout()
{
  ThreadID := DllCall("GetWindowThreadProcessId", "Int", WinExist("A"), "Int", 0)
  HKL := DllCall("GetKeyboardLayout", "uint", ThreadID, "UShort")
  VarSetCapacity(sKbd, 260, 0)
  DllCall("GetLocaleInfo", "uint", HKL
    , "uint", 0x1001
    , "str",  sKbd
    , "uint", 260)
  Return sKbd
}
qvlm_This_and_next_line_added_by_Ahk2Exe:
Exit

oleg-sgh avatar Jan 10 '22 12:01 oleg-sgh

The key components seem to be GetWindowThreadProcessId, GetKeyboardLayout and GetLocaleInfo. I will put this on my backlog, although with low priority. Meanwhile, this will be available for anyone who is interested; pull requests are welcome!

jonaskohl avatar Jan 10 '22 14:01 jonaskohl

Thanks

oleg-sgh avatar Jan 10 '22 14:01 oleg-sgh

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Feb 10 '23 01:02 github-actions[bot]