Automatic Scroll Wheel Speaker Volume Control When Hovering Over the Taskbar

Put simple Tips and Tricks that are not entire Tutorials in this forum
User avatar
Posts: 112
Joined: 01 Aug 2016, 18:17

Automatic Scroll Wheel Speaker Volume Control When Hovering Over the Taskbar

21 Sep 2019, 14:39

This short tip comes directly from the AutoHotkey documentation for the #If directive. I republish it here for those who haven't had a chance to read all the online documentation. Plus, a while back I added it to my main AutoHotkey script and now use my mouse scroll wheel hovering over the Windows Taskbar as my primary method for controlling speaker volume.


A number of other scripts of this type have appeared in the forum, but I have found none quite so simple and easy-to-use.

The #IfWinActive directive restricts Hotkeys to particular active program windows. However, you'll find many times when expressions prove useful for determining whether or not to activate a Hotkey. As in this example, the Hotkey works only when the mouse cursor hovers over the Taskbar. The following script does this by implementing an #If expression directive which checks the mouse cursor location:

Code: Select all

#If MouseIsOver("ahk_class Shell_TrayWnd")
   WheelUp::Send {Volume_Up}
   WheelDown::Send {Volume_Down}

{  MouseGetPos,,, Win
   Return WinExist(WinTitle . " ahk_id " . Win)
I discuss this code (and other examples of mouse cursor location-sensitive AutoHotkey applications) in Chapter Six of the book AutoHotkey Hotkeys: Tips, Tricks, Techniques, and Best Practices.

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 6 guests