AutoHotkey_logo

Automatically Mute Microphone on Keyboard Activity with AutoHotkey

| 11 Comments

I’ve recently upgraded to a mechanical keyboard, and I have to say I’m an addict. The tactile response makes typing on a standard rubber-dome feel like mashing on jello. One problem, however, is that when I’m in a Google Talk/Skype session, typing on the keyboard can be heard through my microphone with the subtlety of an AK-47.

“Yeah, sure, let me look that up here qui…CLACK CLACK CLACK CLACK CLACK”

Goal

Find a free, quick and lightweight way to automatically mute my microphone when I start typing on the keyboard. My solution is an AutoHotkey script that does exactly that.

While this script is designed to mitigate the clicking passed through a mechanical keyboard and desktop microphone, I think it would have similar benefit with laptops and a built-in mic, as typing on the laptop can be loud through the mic in my experience.

Prerequisites/Before You Begin

OS: Windows 7/Windows Vista
Skills: Ability to unzip files and navigate file system
Difficulty: Medium

The AutoHotkey libraries I use in my solution depends on a Vista or Windows 7 workstation. In order to make this work for Windows XP you would need to use an XP-compatible volume library, and I unfortunately don’t have an XP box to find and test that.

You will have to edit the AutoHotkey script I provide in order to make it work for your specific machine, so AutoHotkey or general scripting experience would be extremely helpful. I will, however, try to make things easy for anyone not familiar with AutoHotkey, and feel free to post any questions in the comments.

Downloads

The following is all the software you will need to complete this project. Note that you will have to edit the script MuteOnKeypress to accommodate your specific microphone, as I will describe in this post.

  1. AutoHotkey – Installer for AutoHotkey_L (latest version)
  2. Vista Audio Control Functions for AutoHotkey – library for AutoHotkey that lets us use volume controls on a Vista or Windows 7 machine
  3. CaptureDeviceList – AutoHotkey script (zipped) for discovering what microphone our system uses, based off topology2.ahk
  4. MuteOnKeypress – AutoHotkey script (zipped) that we will run whenever we want the microphone to mute when there’s keyboard activity

Step 1: Download and Install AutoHotkey

Install AutoHotkey from file here: Installer for AutoHotkey_L, or visit the download page at http://www.autohotkey.com/download/ and choose “Installer for AutoHotkey_L.”

Step 2: Install the Vista Audio Control Functions

Download the Vista Audio Control Functions from this direct link, or visit the forum page here and “Download v2.1 with documentation.”

Once downloaded, unzip the VA21.zip to a folder, which should leave you with two files: VA.ahk and VA.html.  The HTML file contains the VA manual, but VA.ahk is what we’re interested in.

Next, find the installation directory of AutoHotkey. This should be under My Computer -> C:/Program Files/AutoHotkey. Once there, create a new folder called Lib. Open the newly-created Lib folder and copy the VA.ahk file into there.

What we’ve done is moved the Vista Audio Control Functions library into the AutoHotkey Lib folder so that AutoHotkey knows where to look for the volume control functions when our scripts need them.

Step 3: Verify Vista Audio Control Functions

Next you will want to download and unzip the CaptureDeviceList AutoHotkey file.  When you execute the file CaptureDeviceList.ahk, you should see something similar to this:

CaptureDeviceList when working properly

If, however, you see something like this:

CaptureDeviceList when VA is not in the proper directory

That means that you don’t have the Vista Audio Control Functions file VA.ahk in the C:/Program Files/AutoHotkey/Lib folder like it should be (see Step 2).  If you can’t even get CaptureDeviceList.ahk to run, you most likely have an AutoHotkey installation error.

Once you can successfully see the device list, we’re ready to move on to the last step.

Step 4: Run MuteOnKeypress

Download and unzip MuteOnKeypress. Run script by double-clicking on the .ahk file and an AutoHotkey icon should remain in your system tray as long as the script is running.  No editing of the MuteOnKeypress.ahk file should be necessary.

Now whenever there is keyboard activity, the system will mute the microphone for 1 second from the last keypress.

The easiest way I found to test the script is to open Sound Recorder (Start -> All Programs -> Accessories -> Sound Recorder) and see what the green bar looks like when I talk then start typing. If everything is working properly, the bar should drop to zero once you start typing, then pick up again after not typing for more than one second (as long as you’re continually talking or blowing on the mic).

Conclusion

I’ve found in my tests that the first click of the keyboard is still heard over the mic before the system mutes the microphone. However, this is a huge, huge improvement from the loud clicking that was previously passed over the voice chat session when I typed.

  • http://www.onelifechanged.com Jacob

    Hey, I love your program. I have some questions for you. I also want to know if you can see about making versed available for Blackberry or others. Please email me!

    Jacob

    • Cam

      We appreciate your interest in Versed and someday we would love to port our game to other devices. Currently though, we don’t have the time or resources available to do so.

      Any comments or suggestions are always welcome. Email us : support@aslingandastone.com

  • Anonymous

    What happened to the program!?!

    • Anonymous

      We’ve updated the links to the zip files on this page. Let me know if you see any issues!

  • Ron

    Ok so, what happened to the “capturedevicelist” download link URL? It’s broke, where do I go to get past this installation process for hotkey?

    • Anonymous

      @ron, the capturedevicelist link has been updated and should work now. Thanks!

  • Panthe Tek

    The link in 2. is broken, the current one can be found at:
    http://www.autohotkey.com/board/topic/21984-vista-audio-control-functions/

    • Scaprara

      All Links seem to be broken. Anyone have updated link to VA_Library?

  • Pingback: How Can I Turn My Keyboards NumPad Into An Audio Mixer In Windows 7? | Click & Find Answer !

  • Oz

    Wonderful ! It works like a charm. Thank you :)

    • Oz

      I made a revised version, with sound feedback, and which allows you to play games while chatting. You version was muting the mic everytime I was moving in my game :)

      http://pastebin.com/WhNy4GB3