Guest User

Untitled

a guest
Oct 18th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. ;0x041E 1054 = Thai
  2. ;0x0409 1033 = English_United_States
  3.  
  4. if !LangID := GetKeyboardLanguage()
  5. {
  6. MsgBox, % "GetKeyboardLayout function failed " ErrorLevel
  7. return
  8. }
  9.  
  10. if (LangID = 0x041E AND GetKeyState("LShift", "SC029")) ; check if left shift + grave accent is pressed
  11. {
  12. ;SetDefaultKeyboard(1033)
  13. <+SC029::~ ; Left shift + Grave accent = ~ (Tilde)
  14. }
  15. return
  16.  
  17. GetKeyboardLanguage()
  18. {
  19. if !ThreadId := DllCall("user32.dll\GetWindowThreadProcessId", "Ptr", WinActive("A"), "UInt", 0, "UInt")
  20. return false
  21.  
  22. if !KBLayout := DllCall("user32.dll\GetKeyboardLayout", "UInt", ThreadId, "UInt")
  23. return false
  24.  
  25. return KBLayout & 0xFFFF
  26. }
  27.  
  28. SetDefaultKeyboard(LocaleID)
  29. {
  30. Global
  31. SPI_SETDEFAULTINPUTLANG := 0x005A
  32. SPIF_SENDWININICHANGE := 2
  33. Lan := DllCall("LoadKeyboardLayout", "Str", Format("{:08x}", LocaleID), "Int", 0)
  34. VarSetCapacity(Lan%LocaleID%, 4, 0)
  35. NumPut(LocaleID, Lan%LocaleID%)
  36. DllCall("SystemParametersInfo", "UInt", SPI_SETDEFAULTINPUTLANG, "UInt", 0, "UPtr", &Lan%LocaleID%, "UInt", SPIF_SENDWININICHANGE)
  37. WinGet, windows, List
  38. Loop %windows% {
  39. PostMessage 0x50, 0, %Lan%, , % "ahk_id " windows%A_Index%
  40. }
  41. }
  42. return
Add Comment
Please, Sign In to add comment