-
Notifications
You must be signed in to change notification settings - Fork 198
Version 1 of Audio Scroll switcher mod #3016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
m417z
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice mod, well done!
| } | ||
|
|
||
| if (g_popupWnd) { | ||
| DestroyWindow(g_popupWnd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the documentation:
A thread cannot use DestroyWindow to destroy a window created by a different thread.
Use SendMessage to close it instead. Currently it won't work, and if the mod is unloaded while the popup is open, it will cause a crash.
| g_popupClassRegistered = false; | ||
| } | ||
|
|
||
| CoUninitialize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might run in a different thread than CoInitializeEx. See: https://github.com/ramensoftware/windhawk/wiki/Mod-lifetime
You can just run CoUninitialize in Wh_ModInit, since it's only needed for GetAudioOutputDevices.
| WNDCLASSEXW wc = {0}; | ||
| wc.cbSize = sizeof(WNDCLASSEXW); | ||
| wc.lpfnWndProc = PopupWndProc; | ||
| wc.hInstance = GetModuleHandle(nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use the mod dll instance. You can use this function:
windhawk-mods/mods/windows-11-taskbar-styler.wh.cpp
Lines 3683 to 3692 in 7355e28
| HMODULE GetCurrentModuleHandle() { | |
| HMODULE module; | |
| if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | | |
| GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, | |
| L"", &module)) { | |
| return nullptr; | |
| } | |
| return module; | |
| } |
|
|
||
| Wh_Log(L"Ctrl+Scroll detected! delta=%d, direction=%d", delta, direction); | ||
|
|
||
| SwitchAudioDevice(direction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to add a throttle (e.g. process at most one message each 400 milliseconds), since some sensitive mice send several messages with a small delta each.
● Summary
Add audio-scroll-switcher mod to switch audio output devices with Ctrl+Scroll on the taskbar.
Displays a Windows 11-style notification popup showing the active device.
Strips parenthetical text from device names for cleaner display.
How it works
Testing