ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Scroll Lock as system volume mute toggle

(1/1)

MilesAhead:
Using AutoHotkey and nircmd makes it easy to use Scroll Lock key to toggle the master volume muting.

NirCmd download site

AutoHotkey download site

There is a built in functionality in AHK to send the volume mute key.  But it may not work on all systems.  More likely to be universal is the nircmd method.  If you run the script with Scroll Lock off then the Scroll Lock indicator LED on the keyboard should serve as the mute indicator.  This gives another visual cue to go with the system tray speaker icon with the line through it.

Here is the script

Edit:  The GetKeyState addition should sync the state of ScrollLock and the volume muting on script startup.


--- Code: Autohotkey ---Sendmode Input;; any other settings here;; sync ScrollLock LED and volume muting on script start;If (GetKeyState("ScrollLock","T"))  Run, nircmd mutesysvolume 1else  Run, nircmd mutesysvolume 0 ; Global Hotkey;~ScrollLock::   Run, nircmd mutesysvolume 2return
The tilde('~') character stops AHK from "eating" the keystroke.  This way the Scroll Lock LED should toggle as you press the key and mute/unmute the volume.  To avoid lighting the LED just delete the tilde.

To access nircmd from anywhere on your system it is recommended to copy it to the Windows directory.  If that is undesirable then copy the executable to a directory in your Path.

eleman:
You don't need an external utility to mute volume.

Try Send {Volume_Mute}
--- End quote ---
in autohotkey. You can make it more functional and robust by adding a variable to keep the state of mute, and an if statement to check it.

MilesAhead:
You don't need an external utility to mute volume.

Try Send {Volume_Mute}
--- End quote ---
in autohotkey. You can make it more functional and robust by adding a variable to keep the state of mute, and an if statement to check it.
-eleman (March 21, 2016, 08:22 AM)
--- End quote ---

I tried that approach first.  It does not work on my Laptop. Probably because I have reversed the FN key so that the special keys are F1 to F12 by default.  I have to hold down the FN key to get the special key actions.  Anyway, if someone wants to change their script they are free to do so.  I find nircmd.exe can do dozens of handy things.  So I see no reason not to use it.

MilesAhead:
You can make it more functional and robust by adding a variable to keep the state of mute, and an if statement to check it.
-eleman (March 21, 2016, 08:22 AM)
--- End quote ---

Instead I added a GetKeyState() on script startup to put them in sync.  The code in my first post has the new lines.

MilesAhead:
Added Shift Scroll Lock to resync the muting to the scroll lock Led indicator without having to rerun the script.  It just calls Reload.  This is useful if you should actually press the dedicated Mute Button throwing the scoll lock Led out of sync. I could poll but how often is muting really used?  I hardly ever mute since unmute would tend to blast the hardware if the volume was up high.  But anyway...   :)


--- Code: Autohotkey ---Sendmode Input;; any other settings here;; sync ScrollLock LED and volume muting on script start;If (GetKeyState("ScrollLock","T"))  Run, nircmd mutesysvolume 1else  Run, nircmd mutesysvolume 0 ; Global Hotkey +ScrollLock::    Reloadreturn ~ScrollLock::   Run, nircmd mutesysvolume 2return

Navigation

[0] Message Index

Go to full version