Repository navigation
|
Hi roblarky,I am trying to achieve a specific feature in Input.Observer: adjusting the system volume by scrolling the mouse wheel when the cursor is hovering over the Windows Taskbar (Scroll up for Volume Up, Scroll down for Volume Down). However, I couldn't find a way to achieve this goal. Could you please guide me on how to implement this? Any guidance or a small script example would be highly appreciated. Thank you for your time! |
Replies: 2 comments 2 replies
|
If Input.Observer doesn’t offer a condition for “cursor is over the taskbar,” a small AutoHotkey v2 script can do this as a separate Windows shortcut: #Requires AutoHotkey v2.0
#HotIf MouseIsOver("ahk_class Shell_TrayWnd") || MouseIsOver("ahk_class Shell_SecondaryTrayWnd")
WheelUp::Send "{Volume_Up}"
WheelDown::Send "{Volume_Down}"
#HotIf
MouseIsOver(title) {
MouseGetPos(,, &windowId)
return WinExist(title " ahk_id " windowId)
}Save it as a |
|
Hi @smystu, thanks for the question, and thanks @sayedrisat for the script. It works, and you can run it from Input.Observer instead of as a separate tool. Using AutoHotkey v2 from Input.ObserverInput.Observer can run AutoHotkey v2 code as an action. Install AutoHotkey v2, then on the General page turn on Enable AutoHotkey, set AutoHotkey executable (for example The script above stays running and handles the wheel itself. The wheel hotkeys only apply while the pointer is over a taskbar, so scrolling everywhere else is untouched. Save it as #Requires AutoHotkey v2.0
#SingleInstance Force
#HotIf MouseIsOver("ahk_class Shell_TrayWnd") || MouseIsOver("ahk_class Shell_SecondaryTrayWnd")
WheelUp::Send "{Volume_Up}"
WheelDown::Send "{Volume_Down}"
#HotIf
MouseIsOver(title) {
MouseGetPos(,, &windowId)
return WinExist(title " ahk_id " windowId)
}Then pick one of these to start it. Start it with Input.Observer (recommended)On the Global events page, open Config loaded (System & lifecycle card), choose AutoHotkey under Run this as, and enter: Run '"' A_AhkPath '" "C:\Scripts\TaskbarVolume.ahk"'Config loaded runs when Input.Observer starts and again after every save, so the volume script is always running while Input.Observer is. This line starts the file and ends right away. Don't paste the whole volume script into Config loaded itself: Input.Observer waits for that script to finish, so at startup you'd be asked whether to keep waiting for it, and every save would stop it. The volume script keeps running if you exit Input.Observer. To close it with Input.Observer, open Engine shutting down on the same card, choose AutoHotkey, and enter: DetectHiddenWindows true
if WinExist("TaskbarVolume.ahk ahk_class AutoHotkey")
WinCloseOr start it from an actionYou can also paste the volume script into an action written as AutoHotkey and run that action once, from a gesture or a hotkey. It then keeps running until you press the stop-all-actions hotkey (default Ctrl+Shift+Alt+F9) or save your configuration, after which you run the action again. That makes Config loaded the better choice for something you want on all the time. Without a running AutoHotkey scriptInput.Observer can also do this with a Wheel — vertical global event, so nothing stays running in the background. On the Global events page, open Wheel — vertical (Mouse & wheel card), leave Swallow the input off, choose Script under Run this as, and enter: cls = WindowGetClassName(ContextGetWindow());
if (cls == "Shell_TrayWnd" || cls == "Shell_SecondaryTrayWnd")
AutoHotkeyExecuteScript("Send IO_WheelDelta > 0 ? \"{Volume_Up}\" : \"{Volume_Down}\"");
-- In the next release: no AutoHotkey at allYour question showed me that gap, so the next release adds it: a wheel event's Steps and Script can read which way the wheel turned. The same event then needs no AutoHotkey: cls = WindowGetClassName(ContextGetWindow());
if (cls == "Shell_TrayWnd" || cls == "Shell_SecondaryTrayWnd") {
if (ContextGetWheelDelta() > 0) KeyboardPressKey(VirtualKey.VolumeUp);
else KeyboardPressKey(VirtualKey.VolumeDown);
}Or in Steps, without code:
What it costs, and the optional exclusion zonesThe wheel event runs this script for every wheel tick, in every window. Scrolling itself isn't slowed: Input.Observer passes the tick on right away and runs the script separately. The script is short, but over a long scroll in a browser it still runs once per tick, only to find it isn't over the taskbar. Over the taskbar, the current version's script also starts AutoHotkey for a moment on each tick. If you'd rather it not run at all away from the taskbar, add exclusion zones. On the Exclusion zones page, draw a zone on each monitor that covers everything except the taskbar. Turn on Vertical wheel and leave every mouse button off, so gestures still work there. Wheel ticks inside a zone scroll as usual, but don't run the wheel event. The zones are fixed rectangles, so redraw them if you move the taskbar or change resolution, and they don't suit an auto-hiding taskbar. With or without them, the script works the same; the zones only save the runs that would find nothing to do. |
Hi @smystu, thanks for the question, and thanks @sayedrisat for the script. It works, and you can run it from Input.Observer instead of as a separate tool.
Using AutoHotkey v2 from Input.Observer
Input.Observer can run AutoHotkey v2 code as an action. Install AutoHotkey v2, then on the General page turn on Enable AutoHotkey, set AutoHotkey executable (for example
AutoHotkey64.exe; the_UIAbuilds can't be used), and apply. After that, AutoHotkey appears next to Steps and Script wherever you write what an action does, including global events.The script above stays running and handles the wheel itself. The wheel hotkeys only apply while the pointer is over a taskbar, so scrolling everywher…