Skip to content

Instantly share code, notes, and snippets.

@Aetet
Created September 16, 2015 21:31
Show Gist options
  • Save Aetet/2be9ff0745b3b4eb4ab3 to your computer and use it in GitHub Desktop.
Save Aetet/2be9ff0745b3b4eb4ab3 to your computer and use it in GitHub Desktop.
capslock language switch with autohotkey
LOCALE_EN := 0x4090409
LOCALE_RU := 0x4190419
CapsLock::
if WinActive("ahk_class ConsoleWindowClass") {
PostMessage, 0x50, 0x02, 0,, A
}
else {
SetFormat, Integer, H
WinGet, WinID,, A
ThreadID := DllCall("GetWindowThreadProcessId", "UInt", WinID, "UInt", 0)
InputLocaleID := DllCall("GetKeyboardLayout", "UInt", ThreadID, "UInt")
PostMessage, 0x50, 0, % ((InputLocaleID == LOCALE_EN) ? LOCALE_RU : LOCALE_EN),, A
SetFormat, Integer, D
}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment