Mute the mic while typing, and unmute when not Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
CaptainProton
Posts: 46
Joined: 06 May 2017, 13:38

Mute the mic while typing, and unmute when not

28 May 2017, 09:17

Hi!

I have a very loud mechanical keyboard, and I often make notes while having Skype calls. So I figured it would be great to have a script that mutes the microphone when the keys are being pressed, and unmutes it after a certain threshold (say, 3 seconds of key inactivity).

I managed to get this working:

Code: Select all

	Input, SingleKey, L1, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
	soundSet,1, , mute, 12
And that's where I'm a little stuck. I had some ideas with looping and persistent, but I haven't managed to make it work. Any help would be greatly appreciated!
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Mute the mic while typing, and unmute when not

28 May 2017, 10:48

Check out SetTimer (and its sample code at the bottom of [that] page) ...
CaptainProton
Posts: 46
Joined: 06 May 2017, 13:38

Re: Mute the mic while typing, and unmute when not

28 May 2017, 14:04

I did it, and without SetTimer :) Short and sweet:

Code: Select all

#SingleInstance force

Loop
{
	Input, SingleKey, T0.5 L1 V, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
	SoundSet, % (ErrorLevel == "Timeout") ? "0" : "1", , mute, 12
}
CaptainProton
Posts: 46
Joined: 06 May 2017, 13:38

Re: Mute the mic while typing, and unmute when not  Topic is solved

28 May 2017, 14:19

Actually, BoBo is right. SetTimer is much better for what I'm doing, so that's what I'll use.

Thanks BoBo!

Code: Select all

SetTimer, KeypressMicMute

KeypressMicMute:
	Input, SingleKey, T0.5 L1 V, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
	SoundSet, % (ErrorLevel == "Timeout") ? "0" : "1", , mute, 12
	return
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Mute the mic while typing, and unmute when not

28 May 2017, 16:14

This might also be of interest:

Code: Select all

Loop
{
	ToolTip % A_TimeIdle " " A_TimeIdlePhysical
	Sleep 100
}
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
CaptainProton
Posts: 46
Joined: 06 May 2017, 13:38

Re: Mute the mic while typing, and unmute when not

28 May 2017, 16:22

jeeswg wrote:This might also be of interest:

Code: Select all

Loop
{
	ToolTip % A_TimeIdle " " A_TimeIdlePhysical
	Sleep 100
}
return
Thanks, but could you please explain how it can be used here? I don't get it.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Mute the mic while typing, and unmute when not

28 May 2017, 18:54

I tested it and it works quite nicely, however, unfortunately it is affected by the mouse as well, not just the keyboard.

Code: Select all

;speakers on if no keyboard/mouse input for 3 seconds or more
Loop
{
	if (A_TimeIdle > 3000) && vIsMute
		SoundSet, % vIsMute := 0,, Mute
	if (A_TimeIdle < 3000) && !vIsMute
		SoundSet, % vIsMute := 1,, Mute
	Sleep 100
	ToolTip, % A_TimeIdle " " A_TimeIdlePhysical
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, inseption86, jaka1 and 291 guests