-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmac-keybindings.ahk
187 lines (158 loc) · 4.49 KB
/
mac-keybindings.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
; ##############################################################################
; ########################### Mac style key bindings ###########################
; ##############################################################################
; =============================================================================
; Global variables
; =============================================================================
WindowSwitching := False
OriginalSize := Map()
; =============================================================================
; Functions
; =============================================================================
RestoreWindow(WinTitle){
KeyOfWindow := WinExist(WinTitle)
if(OriginalSize.Count > 0 && OriginalSize.Has(KeyOfWindow)) {
; Manually restore the window size
PosSize := OriginalSize.Delete(WinActive(WinTitle))
WinMove PosSize[1], PosSize[2], PosSize[3], PosSize[4], WinTitle
} else {
WinRestore WinTitle
}
}
CenterWindow(WinTitle) {
global OriginalSize
WinGetPos &PosX, &PosY, &Width, &Height, WinTitle
OriginalSize[WinActive(WinTitle)] := [PosX, PosY, Width, Height]
OffsetY := -15 ; The height of the task bar is 30 px
OffsetX := 0
WinMove (A_ScreenWidth/2)-(Width/2)+OffsetX, (A_ScreenHeight/2)-(Height/2)+OffsetY,,, WinTitle
}
AlmostMaximize(WinTitle) {
global OriginalSize
IsMinimized := -1
IsMaximized := 1
WindowState := WinGetMinMax(WinTitle)
if(WindowState == IsMaximized) {
WinRestore WinTitle
} else {
WinGetPos &PosX, &PosY, &Width, &Height, WinTitle
OriginalSize[WinActive(WinTitle)] := [PosX, PosY, Width, Height]
}
Width := A_ScreenWidth * 0.9
Height := A_ScreenHeight * 0.9
OffsetY := -15 ; The height of the task bar is 30 px
OffsetX := 0
WinMove (A_ScreenWidth/2)-(Width/2)+OffsetX, (A_ScreenHeight/2)-(Height/2)+OffsetY, Width, Height, WinTitle
}
; NOTE: Always write the hotkeys at the end. Otherwise, global variables will not be
; initialized. For details see: https://www.autohotkey.com/docs/v1/Scripts.htm#auto.
; =============================================================================
; Characters remappings
; =============================================================================
; There is no way to disable Win+L, so instead it's just RCtrl+L for @
>^l::@
#n::Send "~"
#5::Send "["
#6::Send "]"
#7::Send "|"
>^n::Send "~"
>^5::Send "["
>^6::Send "]"
>^7::Send "|"
; For the following two use Powertoys to remap the keys
; #8::Send "{"
; #9::Send "}"
<^>!7::Return
<^>!0::Return
<^>!8::Return
<^>!9::Return
; =============================================================================
; Shortcut remappings
; =============================================================================
; Hotkey using Alt
!a::^a
!c::^c
!f::^f
!n::^n
!p::^p
!r::^r
!s::^s
!t::^t
!v::^v
!w::^w
!x::^x
!z::^z
!+p::^+p
!Enter::^Enter
; Hotkeys using AltGr
<^>!a::^a
<^>!c::^c
<^>!f::^f
<^>!n::^n
<^>!p::^p
<^>!r::^r
<^>!s::^s
<^>!t::^t
<^>!v::^v
<^>!w::^w
<^>!x::^x
<^>!z::^z
<^>!Enter::^Enter
#BackSpace::^BackSpace
#+Up::!+Up
#+Down::!+Down
#+Left::^+Left
#+Right::^+Right
#Up::!Up
#Down::!Down
; ^a::Return
^Left::Return
^Right::Return
#Left::^Left
#Right::^Right
; Conditional hotkeys
#HotIf !WindowSwitching
; Only allow these when not window switching, otherwise navigation in the
; Alt+Tab menu using arrow keys does not work.
!Up::Return
!Down::Return
!Left::Home
!Right::End
<^>!Left::Home
<^>!Right::End
#HotIf
#HotIf WinActive("Firefox")
!l::^l
<^>!l::^l
#!i::^+i
#HotIf
; =============================================================================
; Window Management
; =============================================================================
; Alt+q to close the active window
!+w::WinClose "A"
; <^>!q::WinClose "A"
<^>!q::Return ;disable AltGr+Q for quitting to prevent accidents
; Alt+M/H to minimize the active window
!m:: WinMinimize "A"
!h:: WinMinimize "A"
; Ctrl+Alt+F to toggle full screen
^!f::F11
; Rectanlge keybindings
^#Enter::WinMaximize "A"
^#Backspace::RestoreWindow("A")
^#c::CenterWindow("A")
^#b::AlmostMaximize("A")
; =============================================================================
; Detect keys to override certain hotkeys
; =============================================================================
; The following two keys are used to detect when we are using Alt+Tab. The
; Tilde operator allows the keys to perform its normal function.
~!Tab::{
global WindowSwitching
WindowSwitching := True
}
~Alt Up::{
global WindowSwitching
WindowSwitching := False
}