Skip to content

markbrents/VolumeScroller

Repository files navigation

Volume Scroller Logo

Volume Scroller

Volume Scroller is a program for controlling your computer’s audio volume via the mouse wheel. Just hover your pointer over the icon in the system tray and scroll your wheel to adjust the volume. You can also left-click on the icon to mute/unmute the volume.

Download

You can download the latest release here https://github.com/markbrents/VolumeScroller/releases/download/v1.0.2/VolumeScrollerSetup.exe

How it works

Volume Scroller is a Window Forms program written in C#. The Windows Forms NotifyIcon component makes it easy to put an icon into the system tray. And while it provides events to check mouse clicks, it does not provide a way to tell when the mouse wheel scrolls.

However, in Windows, it is possible to install a mouse hook and be notified when events (including scrolling) happen.

The main problem is to figure out how to tell if the mouse is over our icon when the scroll event happens. Windows 7 introduced a function (Shell_NotifyIconGetRect) to get the location of an icon in the system tray. Unfortunately, using it from .NET involves a lot of Win32 app calls (p/invokes). Fortunately, someone calling themselves quppa figured it out and posted the code in a blog post. I wrapped this code into a class called NotifyIconInfo.

So, the idea is to install a mouse hook and have it call us when the wheel scrolls. Then we’ll get the location of the icon and the location of the mouse. If the mouse is over our icon, we know we should change the volume.

Hooking

Hooking in Windows is a little complicated. Thankfully, there are .NET wrappers that do the hard work for us. The one I choose was MouseKeyHook. Once installed via nuget, it was simply a matter of declaring a variable of type IKeyboardMouseEvents and then setting up the hook and the event listeners.

Volume

The next step was to control the volume. I was surprised how hard that turns out to be from .NET. Thankfully, I ran across the NAudio library that gives makes it easy. I created a simple static class (VolumeController) to wrap the things we need (Volume Up, Volume Down, Mute, etc.)

Icon(s)

As I was testing the program, I decided that I wanted a visual indicator of the volume as it changed. I ended up using Gimp to create several 16x16 icons, each with a different level indicated. Then as the volume changes the icon gets updated to the appropriate one.

Known Issues/Future Item

I run it at work on Windows 10 Enterprise and at home on Windows 10 Home. At work it runs for weeks with no problem. But at home it stops working sometimes. I think it is losing the Windows hook somehow.

Alternatives

Here are some other programs that do similar things.

Volumouse

Volume2

Wheels Of Volume

About

Volume Scroller puts an icon in your Windows system tray. You can mouse over the icon and then scroll your mouse wheel to change the volume.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published