Hotkey for Push-to-Talk + Delay Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
TallgeeseIV
Posts: 2
Joined: 18 May 2018, 08:47

Hotkey for Push-to-Talk + Delay

Post by TallgeeseIV » 18 May 2018, 08:56

So I've written this script that auto-detects my mic that I keep at 97% volume (for this purpose) and allows me to hold a mouse button to temporarily un-mute. What I'm trying to add is a 750ms delay before it re-mutes because I have a tendency in hectic combat to let it go before I'm fully finished speaking. The issue is, adding a sleep command prevents me from repressing it until it has completed the sleep, so I need some way of adding that delay, but making it interuptible if I press the button again. I played with SetTimer a bit with no results but there's a good chance I was using it incorrectly. Any ideas?

Code: Select all

Loop
{
   SoundGet, MicVol,MASTER,VOLUME, %A_Index%
   If (MicVol == 97.00)
   {
      Mic = %A_Index%
	  Break
   }
}

XButton1::
   SoundSet, 0, MASTER, MUTE, %Mic%
   KeyWait XButton1
   SoundSet, 1, MASTER, MUTE, %Mic%
Return
Nightwolf85
Posts: 295
Joined: 05 Feb 2017, 00:03

Re: Hotkey for Push-to-Talk + Delay  Topic is solved

Post by Nightwolf85 » 18 May 2018, 09:24

Does using SetTimer like this work how you want?

Code: Select all

Loop
{
   SoundGet, MicVol,MASTER,VOLUME, %A_Index%
   If (MicVol == 97.00)
   {
      Mic = %A_Index%
	  Break
   }
}

XButton1::
   SetTimer, ReMute, Off
   SoundSet, 0, MASTER, MUTE, %Mic%
   KeyWait XButton1
   SetTimer, ReMute, -750
Return

ReMute:
	SoundSet, 1, MASTER, MUTE, %Mic%
Return
TallgeeseIV
Posts: 2
Joined: 18 May 2018, 08:47

Re: Hotkey for Push-to-Talk + Delay

Post by TallgeeseIV » 18 May 2018, 09:32

It sure does, thank you very much!
Post Reply

Return to “Ask For Help”