-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAutoHotkey.ahk
68 lines (59 loc) · 1.8 KB
/
AutoHotkey.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
ru := DllCall("LoadKeyboardLayout", "Str", "00000419", "Int", 1)
en := DllCall("LoadKeyboardLayout", "Str", "00000409", "Int", 1)
cn := DllCall("LoadKeyboardLayout", "Str", "00000804", "Int", 1)
jp := DllCall("LoadKeyboardLayout", "Str", "00000411", "Int", 1)
pp := A_PriorKey
defaultLn := en
SetLayout(language)
{
ControlGetFocus, control, A
;SplashTextOn,,, % "" . language
PostMessage 0x50, 0, %language%, %control%, A ; WM_INPUTLANGCHANGEREQUEST
}
; Break/Pause button, wait for release
Break Up::
w := DllCall("GetForegroundWindow")
pid := DllCall("GetWindowThreadProcessId", "UInt", w, "Ptr", 0)
l := DllCall("GetKeyboardLayout", "UInt", pid)
if (l = cn) {
SetLayout(defaultLn)
} else {
SetLayout(cn)
}
Return
; LAlt+LShift in any order, wait for release and also pass event back to system
~+LAlt Up::
~!LShift Up::
p := A_PriorKey
t := A_TimeSincePriorHotkey
; If any other keys were pressed don't change language
if ((p = "LShift" || p = "LAlt") && t > 140) {
w := DllCall("GetForegroundWindow")
pid := DllCall("GetWindowThreadProcessId", "UInt", w, "Ptr", 0)
l := DllCall("GetKeyboardLayout", "UInt", pid)
if (l = jp) {
SetLayout(defaultLn)
} else {
SetLayout(jp)
}
}
pp := p
Return
; LControl+LShift in any order, wait for release and also pass event back to system
~^LShift Up::
~+LControl Up::
p := A_PriorKey
t := A_TimeSincePriorHotkey
; If any other keys were pressed don't change language (like ctrl+shift+tab)
if (( p = "LShift" || p = "LControl") && t > 140) {
w := DllCall("GetForegroundWindow")
pid := DllCall("GetWindowThreadProcessId", "UInt", w, "Ptr", 0)
l := DllCall("GetKeyboardLayout", "UInt", pid)
if (l = en) {
SetLayout(ru)
} else {
SetLayout(en)
}
}
pp := p
Return