Push To Talk (PTT) Mute

Post gaming related scripts
FastRide2
Posts: 10
Joined: 04 Dec 2023, 00:13

Push To Talk (PTT) Mute

07 Dec 2023, 03:44

I made a very simple script that lowers your computer volume when you hold your Push To Talk button. It is my first script and it is very basic.... But is very helpful to me as I don't use headphones/earbuds. You will need to change the button around. It is said to mouse button 4 I think? The Browser Back Button. I use it for GTAVRP (shameless plug to my buddy's discord server for his GTARP Server) [URL removed by moderator]. Basically, it just lowers your volume to 20% until you let go of PTT. You can't hear them if they are trying to interupt you but who cares what others have to say right?

Code: Select all

#Requires AutoHotkey v2.0
;Creator: FastRide2
;V1
;Finished 11/13/23 8:56pm
;It is set to the mouse button that does browser back.
;Link to key names: https://www.autohotkey.com/docs/v1/KeyList.htm


	Great:
	if GetKeyState("XButton1")
	{
		;MsgBox "At least one Backbutton key is down."
		SoundSetVolume 20
	}
	else
	{
		;MsgBox "Neither Backbutton key is down."
		SoundSetVolume 100
	}

	^q::
	{
		ExitApp
	}

	GoTo Great
Like I said it was my first ever script and I didn't know how to use loops yet. I am still a beginner with the program. This small bit of code took me a couple of hours to complete. I am sure you could make it even better. But why bother if this works fine?
User avatar
boiler
Posts: 17120
Joined: 21 Dec 2014, 02:44

Re: Push To Talk (PTT) Mute

07 Dec 2023, 06:00

Congrats on your first script! Just in case you wanted to see how it would be with a loop:

Code: Select all

#Requires AutoHotkey v2.0

	loop
	{
		if GetKeyState("XButton1")
		{
			;MsgBox "At least one Backbutton key is down."
			SoundSetVolume 20
		}
		else
		{
			;MsgBox "Neither Backbutton key is down."
			SoundSetVolume 100
		}
	}

	^q::ExitApp

Compact version:

Code: Select all

#Requires AutoHotkey v2.0

loop {
	if GetKeyState("XButton1")
		SoundSetVolume 20
	else
		SoundSetVolume 100
}

^q::ExitApp

Hotkey version (may use less CPU time):

Code: Select all

#Requires AutoHotkey v2.0
~XButton1::SoundSetVolume 20
XButton1 up::SoundSetVolume 100
^q::ExitApp
You can remove the ~ if retaining the original XButton1 functionality is not required.
FastRide2
Posts: 10
Joined: 04 Dec 2023, 00:13

Re: Push To Talk (PTT) Mute

16 Dec 2023, 01:52

boiler wrote:
07 Dec 2023, 06:00
Congrats on your first script! Just in case you wanted to see how it would be with a loop:

Code: Select all

#Requires AutoHotkey v2.0

	loop
	{
		if GetKeyState("XButton1")
		{
			;MsgBox "At least one Backbutton key is down."
			SoundSetVolume 20
		}
		else
		{
			;MsgBox "Neither Backbutton key is down."
			SoundSetVolume 100
		}
	}

	^q::ExitApp

Compact version:

Code: Select all

#Requires AutoHotkey v2.0

loop {
	if GetKeyState("XButton1")
		SoundSetVolume 20
	else
		SoundSetVolume 100
}

^q::ExitApp

Hotkey version (may use less CPU time):

Code: Select all

#Requires AutoHotkey v2.0
~XButton1::SoundSetVolume 20
XButton1 up::SoundSetVolume 100
^q::ExitApp
You can remove the ~ if retaining the original XButton1 functionality is not required.
So many new things there! Well relatively speaking. The last one you did kinda confused me. I thought it needed to be in a constant loop to be able to read.... Or at least when I tried it that way with two hotkeys it didn't work the way I wanted it to. However, I didn't know you could designate Up as a different button.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 6 guests