Check if system sounds are ON or OFF

452 views Asked by At

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.

2

There are 2 answers

1
J. Scott Elblein On

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
2
Jim Hewitt On

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