Mute and Adjust Volume with Keyboard Hotkeys

This is a sequel to my first screencast on the same topic. This improved version uses only AutoHotkey to adjust the volume and mute, and it works on Windows XP and Windows 7.

Here’s the screencast. See below for detailed instructions on how to set it up for yourself.

Step 1: Download and install AutoHotkey.

Step 2: Download volume.ahk (shown below) and put it in the Startup folder. To find the Startup folder, click the Start button, then All Programs. Right-click on the Startup folder and click Open.

Step 3: Run volume.ahk by double clicking on it. This is what’s in volume.ahk.

; Volume control (turn master volume up and down with Ctrl-Alt-Up/Down and
; toggle mute with Ctrl-Alt-.)
^!Up::Send {Volume_Up}
^!Down::Send {Volume_Down}
^!.::Send {Volume_Mute}

That’s it. Now you can use these keyboard shortcuts to adjust the volume and toggle mute.

CtrlAltUp: Increase the volume
CtrlAltDown: Decrease the volume
CtrlAltPeriod: Mute the volume

Comments

 (Post a comment) | Comments RSS feed
  1. Thank you very much. I have been trying to figure it out.
    Interesting that a period and keypad decimal point are
    two different things to windows running but ahk seems to ‘see’
    them both as a period when typed in the script.

    Comment by Rob on May 20, 2010 @ 3:35 pm
  2. You’re welcome. And that is interesting about the period and the number pad decimal point. It kind of makes sense that they both work, but knowing AHK, I bet there’s a way to distinguish them too.

    Comment by Dan on May 20, 2010 @ 8:23 pm
  3. […] to adjust the volume with a keyboard shortcut Update: Here’s an easier way to do […]

    Pingback by How to adjust the volume with a keyboard shortcut on November 14, 2010 @ 1:30 am
  4. […] To translate infrared signals to keyboard commands,[Shawn] decided to base his project off a previous build that used a small program called […]

    Pingback by Control your PC with a remote - Hack a Day on March 5, 2012 @ 7:53 am
  5. Thank you for this script. Volume up and down work, but mute doesn’t work for me. What can I do?

    Comment by Alberto Cabas Vidani on April 16, 2012 @ 2:14 am
  6. @Alberto A quick way to debug the script is to run the Window Spy (on the right-click menu of the AutoHotKey tray icon) to see what happens when you hit the key sequence for mute.

    Comment by Dan on April 16, 2012 @ 10:16 pm
  7. i have been trying to do this but its not working. could i get step by step on what to do

    Comment by jimmy on May 15, 2012 @ 8:00 pm
  8. @jimmy When you say it’s not working, what isn’t? Does the AutoHotkey script run without errors? If so, what happens when you use the shortcut? You can right click on the autohotkey script when it’s running and select Window Spy to get more details about what’s going on.

    Comment by Dan on May 15, 2012 @ 8:16 pm
  9. Thanks, though it makes more sense to me to use page up, page down, and end for it. but then again i forget my Fn key doesn’t work…

    Comment by meltedspades on August 5, 2012 @ 11:20 pm
  10. @meltedspades If that works for you, run with it. If I used PageUp and PageDown I’d be adjusting my volume up and down all day :)

    Comment by Dan on August 5, 2012 @ 11:33 pm
  11. […] https://dan.hersam.com/2010/05/06/mute-and-adjust-volume-with-keyboard-hotkeys/ […]

  12. This only works if you already have the volume bar up. Why bother at that point?

    Comment by unagieel on September 5, 2012 @ 10:52 am
  13. @unagieel It’s a global shortcut – it works whenever you use the keys no matter what you’re doing.

    Comment by Dan on September 6, 2012 @ 2:28 pm
  14. awesome! thx very much!

    I’ve set my UP/DOWN to use the Plus / Minus keys

    ^!=::Send {Volume_Up}
    ^!-::Send {Volume_Down}
    ^!.::Send {Volume_Mute}

    Comment by mr a on September 30, 2012 @ 3:35 pm
  15. Thanks! :) that’s great! i’ll start a new era of shortcuts! :D everrrrything will be a shortcut soon! :D :D

    Comment by mohamed on October 11, 2012 @ 10:14 pm
  16. @mohamed You’re welcome and you have my permission to go crazy with shortcuts for everything!

    Comment by Dan on October 11, 2012 @ 10:43 pm
  17. hey dude im trying to download volume.ahk but its not downloading? it just goes to another page where the volume shorcuts are listed please help

    Comment by george on January 8, 2013 @ 10:37 pm
  18. @george That’s the code of volume.ahk you’re seeing. To download it you can either right click on the link and save link as or click on the link normally and then save the page.

    Comment by Dan on January 9, 2013 @ 10:22 am
  19. @dan thanks man worked perfectly :)

    Comment by george on January 10, 2013 @ 8:43 pm
  20. thanks man this was very helpful!!

    Comment by Matt on January 11, 2013 @ 2:35 am
  21. @Matt You’re welcome.

    Comment by Dan on January 11, 2013 @ 10:27 am
  22. @george Cool!

    Comment by Dan on January 11, 2013 @ 10:46 am
  23. Thank you so much for this tip/tool.
    I spilt beer on my keyboard and I had to connect my old one with no volume hotkeys :)

    Comment by Fernando Lopez on January 22, 2013 @ 6:54 pm
  24. @Fernando I hadn’t even considered that use for this, but I’m glad it helped. Careful with your beer next time ;)

    Comment by Dan on January 22, 2013 @ 9:17 pm
  25. Thanks for the post. This did the job!

    Comment by Vineeth on January 31, 2013 @ 10:01 am
  26. Thanks Dan… nice one… you’re the man! Big Help…

    Comment by Nhel on February 10, 2013 @ 7:35 pm
  27. I can’t thank you enough! Fortunately, this works in desktop mode of Windows 8.

    Thank you!!! :)

    Comment by TBolt on April 2, 2013 @ 12:33 pm
  28. @TBolt That’s great, thanks for letting us know.

    Comment by Dan on April 3, 2013 @ 4:09 pm
  29. it dont work

    Comment by hassan on April 7, 2013 @ 10:05 am
  30. @hassan Try right-clicking on the Autohotkey tray icon and choosing Window Spy (that will give you more information about what’s happening)

    Comment by Dan on April 8, 2013 @ 12:31 pm
  31. Heyup, its working, this is great. But, when I am changing the script and want to use three keys:
    1. +
    2. –
    3. 0
    it is not working. I don’t want to use helping keys like Ctrl-Alt. Is it possible?

    Comment by Veer on April 10, 2013 @ 7:24 am
  32. @Veer You are probably going to regret using normal keys, because it will mean you can’t type a number with a 0, and you won’t be able to type a dash or a plus sign. It’s possible, but a bad idea.

    Comment by Dan on April 10, 2013 @ 1:01 pm
  33. Dan, thanks for posting this. Unfortunately, it’s not working for me. I tried using Window Spy to debug, but nothing gets logged. Any ideas?

    Comment by Rob on April 10, 2013 @ 2:58 pm
  34. @Rob Could you post the text from your Autohotkey script? I can run it to see what’s going on.

    Comment by Dan on April 10, 2013 @ 3:03 pm
  35. Dan, sorry for the delay posting this.

    #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
    ; #Warn ; Enable warnings to assist with detecting common errors.
    SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

    ^!Up::Send {Volume_Up}
    ^!Down::Send {Volume_Down}

    Comment by Rob on April 13, 2013 @ 2:15 pm
  36. @Rob I ran your script and it worked fine. Try this script and see if you get message boxes with Up and Down when you hit the shortcut.

    #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
    ; #Warn ; Enable warnings to assist with detecting common errors.
    SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

    ^!Up::MsgBox, Up
    ^!Down::MsgBox, Down

    Just to clarify, you run the Autohotkey script, then hold down Ctrl+Alt+Up (the arrow key, not on the number pad) or Ctrl+Alt+Down.

    Let me know how it works.

    Comment by Dan on April 15, 2013 @ 6:03 pm
  37. Dan, thanks very much! Force of habit, I was using numpad arrow keys vs. navigation keys (duh). I modified the script as follows and it works great.

    !NumpadUp::Send {Volume_Up 2}
    !NumpadDown::Send {Volume_Down 2}

    Comment by Rob on April 20, 2013 @ 5:41 pm
  38. Yes same here only works while the volume menu is visible.

    Comment by John on September 5, 2013 @ 7:03 am
  39. @John Are you sure? It’s possible it’s adjusting the volume in small increments and it’s not as easy to notice. If you have to have the menu in focus, it’s probably because the Autohotkey isn’t working at all and the up and down arrow keys are adjusting the volume.

    Comment by Dan on September 5, 2013 @ 11:00 am
  40. Helped alot, thanks very much!

    for Windows 8 users trying to locate the [Startup] folder here is the url you can copy and paste into the windows explorer:

    C:\Users\\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

    replace with your username and hit enter.

    Comment by Taylor on September 26, 2013 @ 4:29 pm
  41. @Taylor Thanks for the Windows 8 info.

    Comment by Dan on September 26, 2013 @ 5:08 pm
  42. Yes only works when volume menu is visible. Windows 8 x64.
    Anyone have a fix?

    Comment by Scott on September 28, 2013 @ 10:14 am
  43. @Scott You may want to try a new version of AutoHotkey, since the version found at http://www.autohotkey.com hasn’t been updated for quite some time. Try this one: http://l.autohotkey.net/

    I don’t have a Windows 8 machine to test it on, but if it fixes the problem in Windows 8, please let us know.

    Comment by Dan on September 28, 2013 @ 3:40 pm
  44. I find this method inconvenient because you have to repress the key for every x%
    This i find more convenient:
    $pgUp::
    loop
    {
    if not getKeyState(“pgUp”, “p”)
    break

    Send {Volume_Up}
    Sleep. 100
    }
    return

    $pgDn::
    loop
    {
    if not getKeyState(“pgDn”, “p”)
    break

    Send {Volume_Down}
    Sleep. 100
    }
    return

    Comment by Cohen on October 14, 2013 @ 4:40 pm
  45. Hello! I realize that your post is 4 years old, but I wanted to reply with my thanks. I have a monitor with the speakers built in, and the controls on it went out a year ago, so I used my keyboard volume options. See, I had a really nice, fancy HP keyboard with all of the bells and whistles (with the volume control keys on it), but it finally died, and replacements are ridiculously expensive! Even third party keyboards with the volume controls on the keyboard were too expensive for me, so I picked up a basic LG keyboard with no frills at all.

    So here I was, at the mercy of the Windows volume control on the desktop task bar, which is nice unless you have windows open, or are running other applications. Your little program here has made it so easy for me to adjust the volume without having to click through and around and underneath just to quickly change the volume, so as I said, thank you very much!

    -John

    Comment by John Allen on June 2, 2014 @ 3:44 pm
  46. Hey John, thanks for the comment. I had no idea it had been four years already. Time flies! I’m really happy to hear it made your life a little easier ;)

    Comment by Dan on June 2, 2014 @ 3:49 pm
  47. Hi Dan thanks for posting this, helped me a lot when using external keyboard!

    i was wondering if you are able to post/make hotkeys for increasing/decreasing the screen brightness for laptops?

    Comment by Louis on August 11, 2014 @ 3:35 pm
  48. @Louis You can use the changebrightness command. For example, changebrightness 10 will make the screen brighter, changebrightness -10 will darken the screen.

    Comment by Dan on August 11, 2014 @ 4:38 pm
  49. Thanks dan works good

    Comment by Louis on August 13, 2014 @ 1:07 pm
  50. Thank you very much ;) works perfect for me..

    Comment by Nguyen Tom on May 3, 2015 @ 11:44 pm
  51. Thank you very much. I listen to music at work all the time and have a constant need to adjust the volume. I looked everywhere for something to control the volume on my Win 7 laptop and found nothing but junk. Easy install, and it works. Thank you again.

    Comment by Reggie Smith on July 8, 2015 @ 6:18 pm
  52. You’re welcome! :)

    Comment by Dan on July 10, 2015 @ 4:02 pm
  53. The best thing that worked for me was AutoHotKey script – really easy to implement:

    #PgUp::Send {Volume_Up 1}
    #PgDn::Send {Volume_Down 1}

    or

    Pause::Send {Volume_Up 1}
    ScrollLock::Send {Volume_Down 1}

    Scroll Lock and Pause are two keys that I have never used in 15 years, so now they have a use.
    Just download AutoHotKey (lots of alternative downloads if their main site is broken).

    If you don’t have it installed already, http://www.autohotkey.com/
    Once installed, right click your Desktop, and choose new AutoHotKey file
    Make sure to title the file ending with .ahk (for example, I used “controls.ahk”)
    Paste the code in from above
    Save it, and double click the script in windows explorer
    To run it at startup

    Use the AHK provided “Convert to exe” utility (or you can right click the file and select “compile script”)
    Create the .exe in “C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup”

    Cheers
    Kamil

    Comment by Kamil Wawrzyszko on July 30, 2015 @ 12:27 pm
  54. Thank you guys so much! I too, was in the possession of a keyboard with a mute button and a little wheel to control the volume with. Well, after having used it for close to 7 years, quite a few keys stopped working. I mentioned this to my sister, who responded by buying me a new keyboard- one without those much-loved functions. I hate being or seeming ungrateful and it really is a nice keyboard (pretty backlight in different colors!) so right now I’m thrilled I can use it without feeling bereft, haha. Cheers!

    Comment by Pax on January 20, 2016 @ 4:38 pm
  55. @Pax Sweet. New, colorful backlit keyboard while still being able to adjust the volume and mute = win :)

    Comment by Dan on January 21, 2016 @ 9:37 am

Comments are closed