Show HN: A persistent volume slider for the Windows taskbar

4 months ago 3

A lightweight WinUI 3 volume control application that provides persistent, easily accessible system volume control from the bottom left corner of your screen.

Screenshot

  • Always-on-top volume control - Stays above all windows including taskbar
  • System volume integration - Direct control of Windows master volume
  • Mute toggle - Quick mute/unmute with visual feedback
  • Draggable interface - Move the control anywhere on screen
  • Minimal footprint - No taskbar presence, small memory usage
  • Right-click context menu - Easy exit and run on startup option
  • External sync - Automatically detects and syncs with volume changes made by other applications
  • .NET 9.0
  • Windows 10.0.19041.0 or higher
  • Platforms: x64, x86, ARM64
# From WSL2 dotnet.exe build # From Windows Command Prompt dotnet build # Run the application dotnet run
src/ ├── App.xaml(.cs) # Application entry point and WinUI 3 setup ├── MiniVolumeWindow.xaml(.cs) # Main UI window with volume slider and event handling ├── VolumeManager.cs # High-level volume control API with caching layer ├── AudioDeviceManager.cs # Low-level Windows Core Audio API COM interop wrapper ├── Win32WindowManager.cs # Native window positioning and topmost management ├── StartupManager.cs # Windows startup registry management └── Logger.cs # Debug logging utility with file output
  1. MiniVolumeWindow owns a VolumeManager instance and disposes it on close
  2. VolumeManager caches volume/mute/endpoint state to avoid expensive COM calls
  3. Periodic refresh (1-second timer) syncs with external volume changes
  4. Immediate updates when user interacts for responsive UI
  5. Separation of concerns: UI → VolumeManager → AudioDeviceManager → COM APIs
  • Windows Core Audio API (IAudioEndpointVolume) for direct system volume access
  • Win32 API calls ensure window stays above taskbar and doesn't appear in task switcher
  • Timer-based topmost enforcement overcomes Windows taskbar z-index changes
  • Pointer events enable drag-to-move functionality
  • Polling approach used since Windows audio change events are complex
  • App starts at bottom-left
  • App is initialized with current volume
  • Slider changes system volume
  • Mute button toggles system mute
  • Window stays above taskbar
  • Dragging moves window
  • Right click to exit
  • Always add comments explaining why code is implemented a particular way
  • Test manually after changes to volume or window management code
  • Use Debug.WriteLine/Error for troubleshooting COM/Win32 API issues

Build for distribution: Self-Contained (~80 MB includes .NET 9 and Windows App SKD)

dotnet publish -c Release -r win-x64 --self-contained -p:PublishTrimmed=false -p:WindowsAppSDKSelfContained=true

Output will be in bin/Release/net9.0-windows10.0.19041.0/win-x64/publish/

Note: Trimming must be disabled to preserve COM interop functionality for Windows Audio API.

MIT

Read Entire Article