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.
Ctrl–Alt–Up: Increase the volume
Ctrl–Alt–Down: Decrease the volume
Ctrl–Alt–Period: Mute the volume
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.
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.
[…] to adjust the volume with a keyboard shortcut Update: Here’s an easier way to do […]
[…] To translate infrared signals to keyboard commands,[Shawn] decided to base his project off a previous build that used a small program called […]
Thank you for this script. Volume up and down work, but mute doesn’t work for me. What can I do?
@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.
i have been trying to do this but its not working. could i get step by step on what to do
@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.
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…
@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 :)
[…] https://dan.hersam.com/2010/05/06/mute-and-adjust-volume-with-keyboard-hotkeys/ […]
This only works if you already have the volume bar up. Why bother at that point?
@unagieel It’s a global shortcut – it works whenever you use the keys no matter what you’re doing.
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}
Thanks! :) that’s great! i’ll start a new era of shortcuts! :D everrrrything will be a shortcut soon! :D :D
@mohamed You’re welcome and you have my permission to go crazy with shortcuts for everything!
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
@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.
@dan thanks man worked perfectly :)
thanks man this was very helpful!!
@Matt You’re welcome.
@george Cool!
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 :)
@Fernando I hadn’t even considered that use for this, but I’m glad it helped. Careful with your beer next time ;)
Thanks for the post. This did the job!
Thanks Dan… nice one… you’re the man! Big Help…
I can’t thank you enough! Fortunately, this works in desktop mode of Windows 8.
Thank you!!! :)
@TBolt That’s great, thanks for letting us know.
it dont work
@hassan Try right-clicking on the Autohotkey tray icon and choosing Window Spy (that will give you more information about what’s happening)
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?
@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.
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?
@Rob Could you post the text from your Autohotkey script? I can run it to see what’s going on.
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}
@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.
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}
Yes same here only works while the volume menu is visible.
@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.
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.
@Taylor Thanks for the Windows 8 info.
Yes only works when volume menu is visible. Windows 8 x64.
Anyone have a fix?
@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.
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
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
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 ;)
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?
@Louis You can use the changebrightness command. For example, changebrightness 10 will make the screen brighter, changebrightness -10 will darken the screen.
Thanks dan works good
Thank you very much ;) works perfect for me..
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.
You’re welcome! :)
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
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!
@Pax Sweet. New, colorful backlit keyboard while still being able to adjust the volume and mute = win :)