Modifying Windows Multimedia keyboard volume keys

By jbayer - Last updated: Thursday, May 29, 2014 - Save & Share - Leave a Comment

I recently got a new keyboard, and wanted to use the volume keys.  They worked, but only changed the volume by 2% for each keystroke;  I determined that by setting the volume to 0 and then counting how may keystrokes it took to get to full volume.

While Windows recognizes the volume keys, after extensive searching I couldn’t find any way to adjust the amount of change for each key.

I did find a solution, using a scripting engine called AutoHotKey, available at:

http://ahkscript.org/download/

I found a minimal script which needed work, but finally does what I want.  You will need to install this script in a folder with the following library:

http://www.autohotkey.com/board/topic/21984-vista-audio-control-functions

The script which I wrote intercepts the keys and adjusts the volume.  If you just call it with no parameters, it will use a value of 5 for the delta amount.

If you put a value on the cmd line, it will use that value as the delta.

If you put any other text on the cmd line, it will open a small dialog asking you for the delta.

When you hit the up or down volume key, it will adjust the volume by the specified delta, and then play a tiny sound to let you hear what the current volume is.

Here is the script as I have it working now:

#SingleInstance force
#Include %A_ScriptDir%\VA.ahk

delta := 5
if 0 = 1 ; If a parameter is passed in, use that for the volume delta
{
 index = 1
 if %index% is integer
 delta := %index%
 if %index% is not integer
 InputBox, delta, Volume Delta, Enter Volume Delta
 if ErrorLevel
 delta := 5
}
if delta = ""
 delta := 5
 SoundPlay *-1
MsgBox Volume Delta is %delta%

#UseHook
Volume_Up::
 newVol := VA_GetMasterVolume() + 5
 VA_SetMasterVolume(newVol)
 SoundPlay *-1
return

Volume_Down::
 newVol := VA_GetMasterVolume() - 5
 VA_SetMasterVolume(newVol)
 SoundPlay *-1
return

Posted in AutoHotKey, Programming, Windows • • Top Of Page
333 views

Write a comment

asd