The great code by Long Bong didn't work for me, as I need to use 3 layouts. In non-English layout the script simply disabled all hotkeys.
I played with the code trying to change it so, that it would activate only if Dvorak layout in current window is active.
For some strange reason adding several lines of code made the trick
Before:
Code:
~*Ctrl::
~*Alt::
~*LWin::
~*RWin::
Sleep, 1
If GetKeyState("RAlt") ; This prevents from switching if it was AltGr pressed.
return
MakeQwerty()
WaitRelease()
MakeDefault()
return
After:
Code:
~*Ctrl::
~*Alt::
~*LWin::
~*RWin::
Sleep, 1
If GetKeyState("RAlt") ; This prevents from switching if it was AltGr pressed.
return
WinGet, WinID,, A
ThreadID:=DllCall("GetWindowThreadProcessId", UInt, WinID, UInt, 0)
InputLocaleID:=DllCall("GetKeyboardLayout", UInt, ThreadID, UInt)
if (InputLocaleID=ceil(4026663945)) MsgBox, 1
MakeQwerty()
WaitRelease()
MakeDefault()
return
It is weird as all the code does is getting the number of active layout

. I even failed to make "If" check if layout is 4026663945 (Dvorak) and display some message. "If" doesn't work as i expect it to.
I would appreciate any feed back from gurus, why it is happens.
(I would like to know it, just in case I discover more bugs and will need to improve the script further)
Thank you in advance, Roman.