4

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)
}
Ryan Buening
  • 1,559
  • 2
  • 22
  • 60
  • I'm unfamiliar with AutoHotKey scripts, and [the documentation for `#if` is unclear](https://www.autohotkey.com/docs/commands/_If.htm) about when the scope of the `#if` ends (unlike `if` (without `#`) [which ends at `}`](https://www.autohotkey.com/docs/commands/IfEqual.htm)) - can you repost your script to use `if` instead of `#if`? – Dai Dec 26 '20 at 14:57
  • @Dai The #if statement in AutoHotKey is explained [here](https://www.autohotkey.com/docs/commands/_If.htm). – Ryan Buening Dec 26 '20 at 14:59
  • Indeed, I've updated my comment-reply. – Dai Dec 26 '20 at 14:59

1 Answers1

3

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").

Dai
  • 141,631
  • 28
  • 261
  • 374