-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_Toggle All Microphones.ahk
363 lines (252 loc) · 7.12 KB
/
_Toggle All Microphones.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
;@etofok 07/02/2021
;revision v2 02/06/2024
#NoEnv
#Persistent
#SingleInstance
#Include misc\VA.ahk
#Include Settings.ahk
SetWorkingDir %A_ScriptDir%
Global currentVersion := "Toggle All Microphones `n`nby etofok"
Global b_Microphones
Global b_Sound
Global b_Tooltip
;--------------------------------
; Set Hotkeys and Tooltips
;--------------------------------
if (Hotkey_ToggleAllMicrophonesOnOff) {
Hotkey, %Hotkey_ToggleAllMicrophonesOnOff%, ToggleAllMicrophonesOnOff, UseErrorLevel
Tooltip_Hotkey_ToggleAllMicrophonesOnOff := " (" . ReplaceModifiers(Hotkey_ToggleAllMicrophonesOnOff) . ")"
}
if (Hotkey_ScriptReload) {
Hotkey, %Hotkey_ScriptReload%, ScriptReload, UseErrorLevel
Tooltip_Hotkey_ScriptReload := " (" . ReplaceModifiers(Hotkey_ScriptReload) . ")"
}
;--------------------------------
; Get user launch preferences from Settings.ahk
;--------------------------------
if (Start_with_All_Microphones_Enabled = True) {
b_Microphones := True
} else {
b_Microphones := False
}
if (Start_with_AlertSounds_Enabled = True) {
b_Sound := True
} else {
b_Sound := False
}
if (Start_with_Tooltips_Enabled = True) {
b_Tooltip := True
} else {
b_Tooltip := False
}
;--------------------------------
; Dynamic Tray Menu Labels
;--------------------------------
Global traymenu_Microphones_On := "Double-Click to Turn On" . Tooltip_Hotkey_ToggleAllMicrophonesOnOff
Global traymenu_Microphones_Off := "Double-Click to Turn Off" . Tooltip_Hotkey_ToggleAllMicrophonesOnOff
Global traymenu_Beeps_On := "Sound: On"
Global traymenu_Beeps_Off := "Sound: Off"
Global traymenu_Tooltip_On := "Tooltip: On"
Global traymenu_Tooltip_Off := "Tooltip: Off"
;--------------------------------
; Set Tray Menu
;--------------------------------
Menu, Tray, NoStandard
Menu, Tray, Tip, Toogle All Microphones by etofok
Menu, Tray, Insert, 1&, %currentVersion%, ScriptHotkeys
Menu, Tray, Disable, %currentVersion%
Menu, Tray, Add, etofok Link Tree >>, LinkTree
Menu, Tray, Default, etofok Link Tree >>
Menu, Tray, Add,
if (b_Microphones == True) {
Menu, Tray, Add, %traymenu_Microphones_On%, ToggleAllMicrophonesOnOff
Menu, Tray, Default, %traymenu_Microphones_On%
}
if (b_Microphones == False) {
Menu, Tray, Add, %traymenu_Microphones_Off%, ToggleAllMicrophonesOnOff
Menu, Tray, Default, %traymenu_Microphones_Off%
}
if (b_Sound == True) {
Menu, Tray, Add, %traymenu_Beeps_On%, Toggle_beepSound
Menu, Tray, ToggleCheck, %traymenu_Beeps_On%
}
if (b_Sound == False) {
Menu, Tray, Add, %traymenu_Beeps_Off%, Toggle_beepSound
}
if (b_Tooltip == True) {
Menu, Tray, Add, %traymenu_Tooltip_On%, Toggle_showTooltip
Menu, Tray, ToggleCheck, %traymenu_Tooltip_On%
}
if (b_Tooltip == False) {
Menu, Tray, Add, %traymenu_Tooltip_Off%, Toggle_showTooltip
}
Menu, Tray, Add,
Menu, Tray, Add, Settings, ScriptHotkeys
Menu, Tray, Add,
Menu, Tray, Add, Open Folder, ScriptFolder
Menu, Tray, Add, Reload %Tooltip_Hotkey_ScriptReload%, ScriptReload
Menu, Tray, Add, Exit, CloseApp
;--------------------------------
; Welcome Splash
;--------------------------------
SplashTextOn, 250, 90, , %currentVersion%
Sleep, 1000
SplashTextOff
;--------------------------------
; Autolaunch
;--------------------------------
if (b_Microphones == True) {
TurnAllMicrophonesOn()
return
}
if (b_Microphones == False) {
TurnAllMicrophonesOff()
return
}
Return
; end of autolaunch
;--------------------------------
;--------------------------------
; Toggle Microphone On / Off
;--------------------------------
ToggleAllMicrophonesOnOff() {
if (b_Microphones == False) {
TurnAllMicrophonesOn()
return
}
if (b_Microphones == True) {
TurnAllMicrophonesOff()
return
}
}
TurnAllMicrophonesOn() {
if (b_Sound == True) {
SoundPlay, %A_ScriptDir%\misc\sounds\On.wav
}
if (b_Tooltip == True) {
ShowTooltipAtCursor("Active!")
}
LoopDevices(0)
Menu, Tray, Icon, %A_ScriptDir%\misc\icons\icon_On.ico
Menu, Tray, Rename, %traymenu_Microphones_On%, %traymenu_Microphones_Off%
Menu, Tray, Check, %traymenu_Microphones_Off%
b_Microphones := True
RemoveTooltip(500)
}
TurnAllMicrophonesOff() {
if (b_Sound == True) {
SoundPlay, %A_ScriptDir%\misc\sounds\Off.wav
}
if (b_Tooltip == True) {
ShowTooltipAtCursor("Muted!")
}
LoopDevices(1)
Menu, Tray, Icon, %A_ScriptDir%\misc\icons\icon_Off.ico
Menu, Tray, Rename, %traymenu_Microphones_Off%, %traymenu_Microphones_On%
Menu, Tray, Uncheck, %traymenu_Microphones_On%
b_Microphones := False
RemoveTooltip(500)
}
LoopDevices(OnOff) {
Loop {
mic_state := VA_GetMasterMute("capture:" A_Index)
if (mic_state = "")
break
VA_SetMasterMute(OnOff, "capture:" A_Index)
ObjRelease(device)
}
}
ShowTooltipAtCursor(text) {
MouseGetPos, xpos, ypos
ToolTip, %text%, %xpos%, %ypos%
}
RemoveTooltip(ms) {
Sleep, ms
ToolTip
}
;--------------------------------
; Toggle Beep sounds On / Off
;--------------------------------
Toggle_beepSound() {
if (b_Sound == True) {
b_Sound := False
Menu, Tray, Rename, %traymenu_Beeps_On%,%traymenu_Beeps_Off%
Menu, Tray, Uncheck, %traymenu_Beeps_Off%
SoundBeep(200, 100, 2)
return
}
if (b_Sound == False) {
b_Sound := True
Menu, Tray, Rename, %traymenu_Beeps_Off%,%traymenu_Beeps_On%
Menu, Tray, Check, %traymenu_Beeps_On%
SoundBeep(1500, 100, 2)
return
}
}
;--------------------------------
; Toggle Tooltips On / Off
;--------------------------------
Toggle_showTooltip() {
if (b_Tooltip == True) {
b_Tooltip := False
Menu, Tray, Rename, %traymenu_Tooltip_On%,%traymenu_Tooltip_Off%
Menu, Tray, Uncheck, %traymenu_Tooltip_Off%
SoundBeep(200, 100, 2)
return
}
if (b_Tooltip == False) {
b_Tooltip := True
Menu, Tray, Rename, %traymenu_Tooltip_Off%,%traymenu_Tooltip_On%
Menu, Tray, Check, %traymenu_Tooltip_On%
SoundBeep(1500, 100, 2)
return
}
}
;---------------------------------
; Quick wrapper for sound beeps
;--------------------------------
SoundBeep(Frequency, Duration, Volume) {
SoundGet, MasterVolume
SoundSet, Volume
SoundBeep, Frequency, Duration
SoundSet, MasterVolume
}
CloseApp:
ExitApp
blank:
return
;--------------------------------
; Translate Tooltip Hotkeys to Human Language
;--------------------------------
ReplaceModifiers(str) {
; Replace symbols with corresponding names
str := StrReplace(str, "+", "SHIFT + ") ; start with the "+"!
str := StrReplace(str, "!", "ALT + ")
str := StrReplace(str, "^", "CTRL + ")
str := StrReplace(str, "#", "WIN + ")
return str
}
;--------------------------------
; LinkTree
;--------------------------------
LinkTree:
Run, https://linktr.ee/etofok
return
;--------------------------------
; Hotkeys.ahk
;--------------------------------
ScriptHotkeys:
Run, notepad.exe %A_ScriptDir%/Settings.ahk
return
;--------------------------------
; Locate This Script
;--------------------------------
ScriptFolder:
Run, %a_scriptdir%
return
;--------------------------------
; Reload This Script
;--------------------------------
ScriptReload:
Reload
return