Code: Select all
;--------------------; Keyboard Layout for Language ;--------------------;
; For [LAlt]+[LShift] Button key
#IfWinActive
~LAlt & ~LShift::
SetFormat, Integer, H
LocaleRussian=0x4090409 ; English Language
LocaleEnglish=0x4190419 ; Russian Language
LocaleWinID := WinExist("A")
ThreadID:=DllCall("GetWindowThreadProcessId", "Int", LocaleWinID, "Int", "0")
InputLocaleID:=DllCall("GetKeyboardLayout", "Int", ThreadID)
If(InputLocaleID!=LocaleRussian)
{
PostMessage, 0x50,, % LocaleRussian,, A
}
Else
{
If(InputLocaleID!=LocaleEnglish)
PostMessage, 0x50,, % LocaleEnglish,, A
}
Return
; For [LShift]+[LAlt] Button key
#IfWinActive
~LShift & ~LAlt::
SetFormat, Integer, H
LocaleRussian=0x4090409 ; English Language
LocaleEnglish=0x4190419 ; Russian Language
LocaleWinID := WinExist("A")
ThreadID:=DllCall("GetWindowThreadProcessId", "Int", LocaleWinID, "Int", "0")
InputLocaleID:=DllCall("GetKeyboardLayout", "Int", ThreadID)
If(InputLocaleID!=LocaleRussian)
{
PostMessage, 0x50,, % LocaleRussian,, A
}
Else
{
If(InputLocaleID!=LocaleEnglish)
PostMessage, 0x50,, % LocaleEnglish,, A
}
Return
; For [LControl]+[LAlt] Button key
#IfWinActive
~LControl & ~LAlt::
LocaleJapan=0x4110411 ; Japan Language
PostMessage, 0x50,, % LocaleJapan,, A
Sleep 50
Send !{CapsLock} ; Katakana
Return
; For [LAlt]+[LControl] Button key
#IfWinActive
~LAlt & ~LControl::
LocaleJapan=0x4110411 ; Japan Language
PostMessage, 0x50,, % LocaleJapan,, A
Sleep 50
Send ^{CapsLock} ; Hiragana
Return
;;;
The problem, as I see it, is related to PostMessage . I don’t know how to fix this problem, I don’t have much experience with ahk, I know about the wiki, but I couldn’t resolve my problem with wiki help. Also I already tried to ask in the section in forum with my native language, but nobody answered me. I hope for your help;
P.S. Additional, not so important questions-
1) Is it possible to specify input methods when changing the input language? In order not to put Hiragana or Katakana through keyboard hotkeys, but do something as PostMessage?
2) Can I combine ~LAlt & ~LShift и ~LShift & ~LAlt into one key combination? They had to be duplicated with changeable order, because this order of pressing the key is important for their performance.
Thank you for your time