https://autohotkey.com/board/topic/43043-get-current-keyboard-layout/
User, YMP suggested to use this code:
Code: Select all
F11::
SetFormat, Integer, H
WinGet, WinID,, A
ThreadID:=DllCall("GetWindowThreadProcessId", "UInt", WinID, "UInt", 0)
InputLocaleID:=DllCall("GetKeyboardLayout", "UInt", ThreadID, "UInt")
MsgBox, %InputLocaleID%
Return
Instead of getting the Thread Process ID and storing it in a variable then using it on the GetKeyboardLayout DllCall function, just use 0 for threadID, which means the current thread,
As suggested here: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getkeyboardlayout
The code will look like this:
Code: Select all
F11::
SetFormat, Integer, H
InputLocaleID:=DllCall("GetKeyboardLayout", "UInt", 0, "UInt")
MsgBox, %InputLocaleID%
Return
The code will look like this:
Code: Select all
F11::
InputLocaleID:=DllCall("GetKeyboardLayout", "UInt", 0, "UInt")
MsgBox, %InputLocaleID%
Return
https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-loadkeyboardlayouta
https://docs.microsoft.com/en-us/windows/desktop/Intl/language-identifier-constants-and-strings