Comrades in Arms Discussion Board

Full Version: AHK script to keep mic muted unless pressing PTT keys
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
OK, these AHK scripts seem to be working now. The way they work is that you mute your mic input in your soundcards control panel and when you press any of the defined keys/mouse buttons, it unmutes the mic input whilst you're holding them and mutes it again when you release. The main purpose of this is so that when making gameplay videos, you don't record your own mic input except when you're pressing one of TS3 or TFAR PTT keys.

You can download AHK from here http://ahkscript.org/download/ and you'll also need the VA library so I've included that in the attached zip. Just unzip it so that you have the AutoHotkey folder in My Documents\

I've included three scripts. The first one, "Mute Unless Held (Keyboard).ahk", is suitable for the default TFAR keys (Capslock, Ctrl+Capslock and Alt+Capslock for SR, LR and Diver radios). The first section for Insert is my TS3 PTT key, so either change yours to that or edit the script and the second section for End is my TS3 Whisper key, so do likewise for that.

The second script, "Mute unless Held (Mouse - Capslock).ahk" also works with the default TFAR keys but uses mouse buttons, mapping the TFAR keys to MB5, Ctrl+MB5 and Alt+MB5. AHK can only map to two mouse buttons, which it calls XButton1 and XButton2 but they're probably called Buttons 4 and 5 in your mouse control panel. As above, edit the Insert and End sections of the script to match your TS3 PTT and Whisper keys, or change your TS3 keys to match the script.

The third script, "Mute unless Held (Mouse, Not Capslock).ahk" which is the one I use and prefer, is setup for using End instead of Capslock for TFAR . I've included my edited TFAR userconfig file in the zip, where I've just changed the three PTT keys to use End (207) instead of Capslock. I find this better as a) you don't end up typing in Caps when you use chat, b) it leaves Capslock free for VON if needed and c) I set my TS3 Whisper key to End, so when we're playing ArmA2 I disable the TFAR plugin and enable the Whisper plugin and can use my MB5 for Whisper and when we're playing ArmA3, I disable the Whisper plugin and enable the TFAR plugin and use MB5 for TFAR. As before, edit the Insert section or your TS3 PTT key accordingly.

Whichever script you use, you should be able to check if it's unmuting your mic input properly by opening your soundcard control panel and muting the mic input, then pressing the respective keys and you should see the mute symbol change whilst you're holding them. If you use other voice chat programs like Skype that use different keys, don't forget to unmute your mic input and exit AHK first, otherwise no-one will be able to hear you!

If you want to edit the scripts and need to check the correct keynames to use with AHK, there's a list here http://www.autohotkey.com/docs/KeyList.htm

Let me know if you have any problems with the scripts or any questions and I'll do my best to help.
Thanks doveman! I'll check it out. First, I need to plug my mic input to the sound card, I have it plugged to the motherboard now, I don't even remember the reason why I had to do that...
(03-03-2014, 08:44 AM)Variable link Wrote: [ -> ]Thanks doveman! I'll check it out. First, I need to plug my mic input to the sound card, I have it plugged to the motherboard now, I don't even remember the reason why I had to do that...

Hmm, I hadn't actually considered the case where there's two soundcards (the onboard motherboard audio is basically a soundcard, it's just a lot smaller as it doesn't need to have all the bits that make it an actual removable card). However, I don't think it matters as far as the scripts are concerned and you shouldn't need to change your mic from the motherboard to the soundcard, as the script should just mute whichever mic input is set to Default, which can be set by right-clicking on the systray speaker icon, Recording Devices and then right-click on the relevant device and "Set as Default Device".

I recall you had problems getting the mic working well when you got your new soundcard, so I think that's why you've still got it plugged into the motherboard and I can't see why it should work any better now, so it's probably a waste of time trying. Having said that, the soundcard should in theory sound a bit better than the onboard, so you might want to try it again sometime.
Already switched mic to the sound and it's working well. Tonight you guys will be able to tell me if the sound quality got better as I hope it did.

I think the reason I switched the mic to the MB was Bandicam, which I don't use anymore.
(03-04-2014, 08:48 AM)Variable link Wrote: [ -> ]Already switched mic to the sound and it's working well. Tonight you guys will be able to tell me if the sound quality got better as I hope it did.

I think the reason I switched the mic to the MB was Bandicam, which I don't use anymore.

Ah, cool then, great if it's working. If it sounds OK to you when you test it then it should to everyone else as well but things don't always do what they should Wink
I've learnt a bit more about AHK and there are some errors in my scripts. Firstly

Send {CTRL down} {END down}

will send a space as well as Ctrl+END, so what it needs to be is

Send {CTRL down}{END down}

However, we probably don't need to even send the Ctrl as that's already being pressed, so it will probably be better to use

^Xbutton1::
VA_SetMasterMute(!VA_GetMasterMute("capture"), "capture")
Send, {blind}{End down} ; the control key is already down so is it actually required?
Keywait, XButton2
Send, {blind}{End up}
VA_SetMasterMute(!VA_GetMasterMute("capture"), "capture")
return

for Ctrl+End when pressing Ctrl+MB1

and

!Xbutton1::
VA_SetMasterMute(!VA_GetMasterMute("capture"), "capture")
Send, {blind}{End down} ; the Alt key is already down so is it actually required?
Keywait, XButton1
Send, {blind}{End up}
VA_SetMasterMute(!VA_GetMasterMute("capture"), "capture")
return

for Alt+End when pressing Alt+MB1.

Also bear in mind that MB1 will only send End when the AHK script tells it to, so for example if you're holding Shift (to sprint) and press MB1, it won't send End and thus the radio won't trigger. To fix this, we need to add a mapping for Shift+MB1:

+Xbutton1::
VA_SetMasterMute(!VA_GetMasterMute("capture"), "capture")
Send, {blind}{End down}
Keywait, XButton1
Send, {blind}{End up}
VA_SetMasterMute(!VA_GetMasterMute("capture"), "capture")

which should do the trick.