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
jackdunning
Posts: 94
Joined: 01 Aug 2016, 18:17
Facebook: https://www.facebook.com/ComputorEdgeEBooks/posts
Contact:

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.

Image

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}
#If

MouseIsOver(WinTitle)
{  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 5 guests