autohotkey

Change volume using mouse scroll wheel over taskbar with multiple monitors


I use the AutoHotkey script below which allows me to change the volume using my mouse scroll wheel when hovering over the taskbar in Windows 10. However, this only works on the monitor that is selected as the "main display". I have multiple displays that are used to extend my desktop. Using the mouse wheel scroll on the extended monitors taskbars does not work.

Is there a way to modify the script to work with extended displays?

SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

;--------------------------------------------------------------------
; Change volume using mouse scroll wheel over taskbar
;--------------------------------------------------------------------

#if MouseIsOver("ahk_class Shell_TrayWnd")

WheelUp::
Send {Volume_Up}
return

WheelDown::
Send {Volume_Down}
return

MouseIsOver(WinTitle) {
    MouseGetPos,,, Win
    return WinExist(WinTitle . " ahk_id " . Win)
}

Solution

  • Only the "Main display"'s desktop's taskbar has the Window class Shell_TrayWnd.

    Secondary taskbars have the Window class Shell_SecondaryTrayWnd.

    I'm not familiar with AutoHotKey's scripts' syntax - so I can't give you an answer you can copy+paste - but you need to change the logical-condition in the If statement to check for MouseIsOver("ahk_class Shell_TrayWnd") **OR** MouseIsOver("ahk_class Shell_SecondaryTrayWnd").