-2

I've a vb.net application which has a button; when I click the button it should display a message stating whether the system sounds are on or off.

How do I do it?

By System sounds I mean the sounds played by the system such as "Asterisk", "hand" etc. These sounds usually occur when a message box pops up. These sounds can be turned off or on in the volume mixer. I want my application to on the click of a button show a message "System sounds are ON" or "... OFF" as a result of system sounds beings turned on or off in the volume mixer.

Below image shows system sounds turned off in the volume mixer window.

Somanna
  • 284
  • 1
  • 13

2 Answers2

2

You can do this with the NuGet package AudioSwitcher.AudioApi.CoreAudio and the following code.

Imports AudioSwitcher.AudioApi.CoreAudio

Module Module1

    Sub Main()

        Dim dev As CoreAudioDevice = New CoreAudioController().DefaultPlaybackDevice

        If dev.IsMuted Then
            Console.WriteLine("Volume muted.")
        Else
            Console.WriteLine("Volume not muted.")
        End If

    End Sub

End Module
Jim Hewitt
  • 1,726
  • 4
  • 24
  • 26
1

If you change the System sound scheme to "No Sounds" (meaning System sounds are all Off):

enter image description here

then the HKEY_CURRENT_USER\AppEvents\Schemes default key will show as .None; else, it'll show the name of the scheme. You can test is system sounds are all off bu checking for .None.

    If Registry.GetValue("HKEY_CURRENT_USER\AppEvents\Schemes", "", String.Empty).ToString = ".None" Then

        Debug.Print("System Sounds are Off")

    Else

        Debug.Print("System Sounds are On")

    End If
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
  • But I'm OFFing and ONing the system sounds from the volume mixer. Doing so doesn't change the registry value you've mentioned. – Somanna Jun 04 '20 at 15:12