Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;0x041E 1054 = Thai
- ;0x0409 1033 = English_United_States
- if !LangID := GetKeyboardLanguage()
- {
- MsgBox, % "GetKeyboardLayout function failed " ErrorLevel
- return
- }
- if (LangID = 0x041E AND GetKeyState("LShift", "SC029")) ; check if left shift + grave accent is pressed
- {
- ;SetDefaultKeyboard(1033)
- <+SC029::~ ; Left shift + Grave accent = ~ (Tilde)
- }
- return
- GetKeyboardLanguage()
- {
- if !ThreadId := DllCall("user32.dll\GetWindowThreadProcessId", "Ptr", WinActive("A"), "UInt", 0, "UInt")
- return false
- if !KBLayout := DllCall("user32.dll\GetKeyboardLayout", "UInt", ThreadId, "UInt")
- return false
- return KBLayout & 0xFFFF
- }
- SetDefaultKeyboard(LocaleID)
- {
- Global
- SPI_SETDEFAULTINPUTLANG := 0x005A
- SPIF_SENDWININICHANGE := 2
- Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "Int", 0)
- VarSetCapacity(Lan%LocaleID%, 4, 0)
- NumPut(LocaleID, Lan%LocaleID%)
- DllCall("SystemParametersInfo", "UInt", SPI_SETDEFAULTINPUTLANG, "UInt", 0, "UPtr", &Lan%LocaleID%, "UInt", SPIF_SENDWININICHANGE)
- WinGet, windows, List
- Loop %windows% {
- PostMessage 0x50, 0, %Lan%, , % "ahk_id " windows%A_Index%
- }
- }
- return
Add Comment
Please, Sign In to add comment