Multiple Push to Talk Keys ~ With Delays & Noises?

Ask gaming related questions (AHK v1.1 and older)
lacrzach
Posts: 2
Joined: 17 Aug 2017, 22:26

Multiple Push to Talk Keys ~ With Delays & Noises?

17 Aug 2017, 22:54

Hey! I'm new to the site, and the program, so please, bear with me.

After searching around on the forums and just googling for a while, I still can't figure out how to write a script to preform what I would like.

What I am trying to do: I want create a script that mutes my mic when it is started. I then want said script to allow my mic to be unmuted when a key is held down. When the key is released, I then want my mic to mute again. Basically, a push to talk key. I also, if possible, do not want my mic to instantly mute, I would like it to remain unmuted for like half a second after the key is released. It would put the icing on the cake if the script was also able to play a short and quiet noise when my mic was activated (so I would know people can hear me, kinda like discords push to talk system) and another quiet noise when the key is released.

After looking around and reading mainly old posts (I couldn't find anything very new, or friendly to new users who have little coding experience) I have this:

Code: Select all

k::
SoundSet, 0, MASTER, Mute, 7
KeyWait, k ;
SoundSet, 1, MASTER, Mute, 7
Return
with k being the push to talk key in this instance. However, my mic is unmuted still, so this serves no function (if my voice is set to "Always On" on discord already, then this is pointless without a mute).

Now, this is probably a lot to ask, but I figure you are the people to ask. If you are willing to help, please, keep in mind that I am pretty new to this. If you have tutorial suggestions, I am open to learning and not just getting free code (although I won't argue with you if you are willing to do that, with "that" being some code ;) ).

To break it down, I want to try and get code to 1) Mute mic when script is launched 2) Have mic unmute while a key is held down 3) Have mic mute after key is released.

I figure this is a solid place to start. Is the code I have already almost right? Thank you in advance.
User avatar
Spawnova
Posts: 555
Joined: 08 Jul 2015, 00:12
Contact:

Re: Multiple Push to Talk Keys ~ With Delays & Noises?

18 Aug 2017, 08:59

SoundSet does not work for my microphone, so I cannot test, but this script should work if compatible.

Code: Select all

supportsMicrohpone := SetMute(1) ;when script starts mute microphone
msgbox % supportsMicrohpone ;check if microphone is supported

k::
SoundGet, muteToggle, Microphone, volume ;get mute state ON/OFF
if (muteToggle == "ON") ;if muted, unmute
	SetMute(0)
else ;else mute
	SetMute(1)
return

j::
SoundGet, muteToggle, Microphone, mute
if (muteToggle == "ON") ;if muted, unmute
	SetMute(0)
keywait,j ;wait for j to be released
SetMute(1) ;mute when finished holding j
return

SetMute(state) {
	SoundSet, %state%, Microphone, mute
	return % errorlevel
}
lacrzach
Posts: 2
Joined: 17 Aug 2017, 22:26

Re: Multiple Push to Talk Keys ~ With Delays & Noises?

18 Aug 2017, 19:38

Spawnova wrote:SoundSet does not work for my microphone, so I cannot test, but this script should work if compatible.

Code: Select all

supportsMicrohpone := SetMute(1) ;when script starts mute microphone
msgbox % supportsMicrohpone ;check if microphone is supported

k::
SoundGet, muteToggle, Microphone, volume ;get mute state ON/OFF
if (muteToggle == "ON") ;if muted, unmute
	SetMute(0)
else ;else mute
	SetMute(1)
return

j::
SoundGet, muteToggle, Microphone, mute
if (muteToggle == "ON") ;if muted, unmute
	SetMute(0)
keywait,j ;wait for j to be released
SetMute(1) ;mute when finished holding j
return

SetMute(state) {
	SoundSet, %state%, Microphone, mute
	return % errorlevel
}

Hey! Thanks for the speedy reply. I get the message "Mixer Doesn't Support This Component Type" when I run the script, and then it doesn't work. Any idea what this means? Does this mean it isn't compatible? I have a Blue Snowball Microphone if that means anything to you.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 88 guests