Created
October 27, 2020 17:19
-
-
Save carneloot/934da85660e9768805eef48345b43cf3 to your computer and use it in GitHub Desktop.
Mute mic script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; =================================== | |
| ; | |
| ; Use this file to find out which device channel is your microfone. | |
| ; | |
| ; Author: Matheus Carnelutt | |
| ; based on: https://www.autohotkey.com/boards/viewtopic.php?t=15509 | |
| ; | |
| ; =================================== | |
| SetBatchLines -1 | |
| SplashTextOn,,, Gathering Soundcard Info... | |
| ; Most of the pure numbers below probably don't exist in any mixer, but they're queried for completeness. | |
| ; The numbers correspond to the following items (in order): CUSTOM, BOOLEANMETER, SIGNEDMETER, PEAKMETER, | |
| ; UNSIGNEDMETER, BOOLEAN, BUTTON, DECIBELS, SIGNED, UNSIGNED, PERCENT, SLIDER, FADER, SINGLESELECT, MUX, | |
| ; MULTIPLESELECT, MIXER, MICROTIME, MILLITIME | |
| ControlTypes = VOLUME,ONOFF,MUTE,MONO,LOUDNESS,STEREOENH,BASSBOOST,PAN,QSOUNDPAN,BASS,TREBLE,EQUALIZER,0x00000000, 0x10010000,0x10020000,0x10020001,0x10030000,0x20010000,0x21010000,0x30040000,0x30020000,0x30030000,0x30050000,0x40020000,0x50030000,0x70010000,0x70010001,0x71010000,0x71010001,0x60030000,0x61030000 | |
| ComponentTypes = MASTER,HEADPHONES,DIGITAL,LINE,MICROPHONE,SYNTH,CD,TELEPHONE,PCSPEAKER,WAVE,AUX,ANALOG,N/A | |
| ; Create a ListView and prepare for the main loop: | |
| Gui, Add, Listview, w400 h400 vMyListView, Component Type|Control Type|Setting|Mixer | |
| LV_ModifyCol(4, "Integer") | |
| SetFormat, Float, 0.2 ; Limit number of decimal places in percentages to two. | |
| Loop ; For each mixer number that exists in the system, query its capabilities. | |
| { | |
| CurrMixer := A_Index | |
| SoundGet, Setting,,, %CurrMixer% | |
| if ErrorLevel = Can't Open Specified Mixer ; Any error other than this indicates that the mixer exists. | |
| break | |
| ; For each component type that exists in this mixer, query its instances and control types: | |
| Loop, parse, ComponentTypes, `, | |
| { | |
| CurrComponent := A_LoopField | |
| ; First check if this component type even exists in the mixer: | |
| SoundGet, Setting, %CurrComponent%,, %CurrMixer% | |
| if ErrorLevel = Mixer Doesn't Support This Component Type | |
| continue ; Start a new iteration to move on to the next component type. | |
| Loop ; For each instance of this component type, query its control types. | |
| { | |
| CurrInstance := A_Index | |
| ; First check if this instance of this instance even exists in the mixer: | |
| SoundGet, Setting, %CurrComponent%:%CurrInstance%,, %CurrMixer% | |
| ; Checking for both of the following errors allows this script to run on older versions: | |
| if ErrorLevel in Mixer Doesn't Have That Many of That Component Type,Invalid Control Type or Component Type | |
| break ; No more instances of this component type. | |
| ; Get the current setting of each control type that exists in this instance of this component: | |
| Loop, parse, ControlTypes, `, | |
| { | |
| CurrControl := A_LoopField | |
| SoundGet, Setting, %CurrComponent%:%CurrInstance%, %CurrControl%, %CurrMixer% | |
| ; Checking for both of the following errors allows this script to run on older versions: | |
| if ErrorLevel in Component Doesn't Support This Control Type,Invalid Control Type or Component Type | |
| continue | |
| if ErrorLevel ; Some other error, which is unexpected so show it in the results. | |
| Setting := ErrorLevel | |
| ComponentString := CurrComponent | |
| if CurrInstance > 1 | |
| ComponentString = %ComponentString%:%CurrInstance% | |
| LV_Add("", ComponentString, CurrControl, Setting, CurrMixer) | |
| } ; For each control type. | |
| } ; For each component instance. | |
| } ; For each component type. | |
| } ; For each mixer. | |
| Loop % LV_GetCount("Col") ; Auto-size each column to fit its contents. | |
| LV_ModifyCol(A_Index, "AutoHdr") | |
| SplashTextOff | |
| Gui, Show | |
| return | |
| GuiClose: | |
| ExitApp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; =================================== | |
| ; | |
| ; This script mutes your microfone when you press a specific key. | |
| ; It also plays a beep or two so you can know if your mic is muted or not. | |
| ; | |
| ; Muted: one beep | |
| ; Unmuted: two beeps | |
| ; | |
| ; Author: Matheus Carnelutt | |
| ; based on: https://www.autohotkey.com/boards/viewtopic.php?t=15509 | |
| ; | |
| ; =================================== | |
| ; Beep onfigs | |
| high_freq := 880 | |
| sound_delay := 75 | |
| ; Mic device id. Use the other file to find out | |
| mic_id := 9 | |
| ; Run script on pressing pause. You can configure your own shortcurt based on this website https://www.autohotkey.com/docs/Hotkeys.htm | |
| Pause:: | |
| SoundSet, +1, MASTER, mute, mic_id | |
| SoundGet, master_mute, , mute, mic_id | |
| if (master_mute = "On") { | |
| SoundBeep, high_freq, sound_delay | |
| } else { | |
| SoundBeep, high_freq, sound_delay | |
| SoundBeep, high_freq, sound_delay | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment