AudioSwap hotfix 2.3.0#4698
Conversation
Adds a network toggle feature to the system tray, allowing users to enable or disable network adapters with a single click. The implementation includes error logging, UAC handling, and dynamic icon updates based on network status.
Added a readme section for the Network Toggle mod, detailing its features and functionality.
using original code snippet from: https://github.com/ramensoftware/windhawk/wiki/Mods-as-tools:-Running-mods-in-a-dedicated-process Icon does not disappear on explorer.exe restart Removed -lwtsapi32 and -lwininet Removed <wininet.h>, <wtsapi32.h>, and all #pragma directives. Removed the unused RunPowerShellCommandAsSystem function. Removed SetThreadPriority; the tray UI thread now runs at standard priority as requested. overall stability and maintenance upgrade
Updated usage instructions and added known issues section.
This mod adds a tray icon for toggling between two audio outputs, allowing users to switch devices quickly.
Updated version to 1.1.0 and improved device selection handling. now devices can be automatically detected and selected via Right Click on the icon.
Updated device selection persistence to use Windhawk storage instead of registry. Simplified loading and saving of device selections.
Updated version to 1.1.1 and added new features including opening WindHawk.exe from the mod itself, new icons in the settings.
created MicSwap mod that allows toggling between two audio input devices from the system tray.
new features and functions added. scroll capability over 2 devices can be selected.
bug fixes and improvements. added a red dot over the icon when muted. persistent across restarts.
UNICODE-dependencies converted to explicit W/INFOW; -DUNICODE -D_UNICODE removed
Updated version to 1.5.0 and added custom icon support.
Added WM_RELOAD_ICONS message to reload tray icons and updated icon handling in WhTool_ModSettingsChanged function.
### v2.2.0 - New: Right-click → **Sound Settings...** opens Windows Sound dialog directly on the Playback tab. - New: Middle-click tray icon → compact volume slider popup with a custom dark design. Drag to adjust output volume live; click outside or press Escape to close. - New: Scroll wheel over the tray icon (Click to Swap mode) adjusts output volume, matching native Windows sound icon behaviour.
### v2.0.0 - **Complete rebuild.** Mod renamed to Net-Toggle. - New: **DNS Monitoring** — The icon monitors your connection and changes color if your internet drops out (configurable in Mod Settings). - New: **WiFi-style tray icon** with 5 color states (Red / Yellow / Blue / Green / Grey). - New: Middle-click → **Full Network Reset** (flush DNS, release/renew, winsock + IP reset). - New: Right-click context menu — toggle network, open Network Settings, or exit. - New: Donate button on the mod page. - Improved: Tray icon is now independent from the Windhawk app and no longer groups with it in the taskbar. - Improved: Tray icon persists reliably across Explorer restarts. - Improved: Icon stays in sync even if you disable your adapter directly in Windows Settings. - Fixed: Occasional hangs during network toggles or timeouts. - Fixed: Tray icon could show the wrong state if a toggle failed.
fix: production-readiness audit fixes (v2.0.0) - Offload DNS ping to worker thread (prevents UI thread block) - CoInitializeEx(COINIT_APARTMENTTHREADED) + HRESULT check in all 3 threads - Atomic g_networkIsUp read via InterlockedOr in ProcessTrayClick - Remove dead WM_UPDATE_DNS_STATE define and handler - lstrcpyW → wcscpy_s for AUMID string copy - GetModuleHandle → GetModuleHandleW - Update stale log message in ModInit
Updated network reset functionality, improved context menu options and general patches.
fixes implemented (hopefully) and optional changes discarded due to functionality issues Replaced `powershell.exe` spawn in `CheckActualNetworkState` with native `GetAdaptersAddresses` API calls to eliminate startup blocking and latency.
Updated compiler options to include WIN32_LEAN_AND_MEAN for better compatibility.
-DWIN32_LEAN_AND_MEAN removed. -D flag broke the automatic PR validation
added screenshots added -DWIN32_LEAN_AND_MEAN Fixed CheckActualNetworkState Raised debounce from 2s → 10s — Prevents the user from firing a second toggle before the first PowerShell command has had time to fully apply its changes
- Add secondary (fallback) DNS server support - New default check: real DNS query (fixes false "unreachable" on networks that block TCP/53) — fixes ramensoftware#4288 - New per-server check methods: UDP DNS / TCP 53 / DoT 853 / DoH 443 - New Orange icon state: primary down, fallback still up - Tooltip shows per-server status - Minor reliability fixes (DNS state reads, shutdown handle cleanup)
A lightweight tray icon that shows a mini task manager popup with live CPU, GPU and RAM usage, plus the single top-consuming process for each.
1. Removed persistent registry writes: Replaced RegCreateKeyExW / RegGetValueW with Windhawk's native Wh_SetIntValue and Wh_GetIntValue to store the refresh interval cleanly. 2. Fixed double-buffer for top CPU detection: Introduced g_curProcs alongside g_prevProcs to ensure that we don't read and write to the same buffer in a single pass, which caused the top process to intermittently drop out. 3. Optimized GPU Process Lookup: Removed the per-tick CreateToolhelp32Snapshot call for the GPU process name and reused the name that was already collected in the process loop. 4. Clamped GPU to 100%: Added limits to prevent grandTotal and topVal from displaying over 100% since PDH sums across all engines. 5. Debounced UI Popup Toggling: Added a 200ms debounce to the tray icon left-click to prevent the popup from immediately reopening when clicking the tray icon to close it. 6. Removed g_statsLock : Removed the CRITICAL_SECTION because all reads and writes to those stats run exclusively on the tray thread's message loop, making locking unnecessary. 7. README Screenshot: Added a screenshot to the README section.
Updated version to 2.2.1, added persistent mute feature and general performance patches.
Submission reviewNote: This review was done by Claude, and then refined manually. Due to the amount of submissions, doing a fully manual review for each pull request is no longer feasible. Thank you for understanding. Please address the following issues. The items in the collapsed sections are optional, so it's your call whether to address them. Note: I haven't verified the claims manually. If it's a mistake and the code is correct as is, let me know. The new Persistent Mute feature has a device-tracking bug that leaves a device stuck muted. Persistent mute never re-tracks the muted device after a swap, and never unmutes the previous one. When persistent mute is on and you cycle to a new device, // CycleAudioDevice — lines ~2022-2027
if (keepMute) {
ApplyMute(nullptr, TRUE); // mutes the new default...
HWND hw = g_trayHwnd; // ...but g_mutedDeviceId still points to the OLD device
if (hw) PostMessageW(hw, WM_UPDATE_TRAY_STATE, 0, 0);
}The same omission is in the
Fix: when persistent mute re-applies the mute, release the previously muted device, mute + track the new default (you already know its ID — if (keepMute) {
WCHAR prevId[512];
{ EnterCriticalSection(&g_stateLock); lstrcpynW(prevId, g_mutedDeviceId, 512); LeaveCriticalSection(&g_stateLock); }
if (prevId[0] && wcscmp(prevId, localIds[validSlot]) != 0)
ApplyMute(prevId, FALSE); // release the device we no longer point at
ApplyMute(localIds[validSlot], TRUE); // mute the new default
EnterCriticalSection(&g_stateLock);
lstrcpynW(g_mutedDeviceId, localIds[validSlot], 512);
LeaveCriticalSection(&g_stateLock);
Wh_SetStringValue(L"MutedDeviceId", localIds[validSlot]);
HWND hw = g_trayHwnd;
if (hw) PostMessageW(hw, WM_UPDATE_TRAY_STATE, 0, 0);
}The Optional improvements
Minor polish — none of this affects users, so it's your call.
Functionality notes
Non-critical observations about the feature behavior itself.
|
|
@m417z |
|
It's a skill that I maintain, created from past manual reviews and Windhawk knowledge base (API, wiki, existing mods, etc.), running in an environment with the ability to query some of these knowledge base sources. Currently I don't plan on publishing it. |
|
i see, that is really cool man keep it up. |
Updated version to 2.3.0 with new features and fixes. used new skills i made based on the entire Windhawk repo and wiki.
|
took some time to craft the skill but it sure was worth it. hopefully that is good and doesn't need more tweaking. |
|
A small COM usage issue. I haven't reviewed the other notes. Submission reviewNote: This review was done by Claude, and then refined manually. Due to the amount of submissions, doing a fully manual review for each pull request is no longer feasible. Thank you for understanding. Please address the following issues. The items in the collapsed sections are optional, so it's your call whether to address them.
Optional improvements
Minor polish — none of this affects users in normal operation, so it's your call.
Functionality notes
Non-critical observations about the Persistent Mute feature and the live dashboard refresh — feature behavior, no integration impact.
|
persistent mute device-tracking fix and fixed various crash issues.
Changelog
If this pull request updates an existing mod, describe the changes below:
added Persistent Mute option
general patches
added screenshots to readme
Mod authorship
If this pull request introduces a new mod, please complete the section below.
This mod was created by:
Please select the options that best apply. Your selection does not affect the acceptance criteria, but it helps reviewers understand the context of the code and provide relevant feedback.