How can you get the speakers volume and get a notice when the volume changes. Thanks
Printable View
How can you get the speakers volume and get a notice when the volume changes. Thanks
I don't think you can get the Speaker volume, but you can get the system volume.
Well how would you find out the System Volume, I am guessing that there is some API to do it.
Put the following in a Form with a Timer.
Code:Private Declare Function waveOutSetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, ByVal dwVolume As Long) As Long
Private Declare Function waveOutGetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, lpdwVolume As Long) As Long
Dim OldVolume
Function GetVolume() As Variant
' Get the volume
Retval = waveOutGetVolume(1, volume)
volume = volume And &HFFFF
volume = Hex(volume)
GetVolume = volume
End Function
Private Sub Form_Load()
'Get the stsrting volume
OldVolume = GetVolume()
End Sub
Private Sub Timer1_Timer()
'Check if Volume has changed
If GetVolume <> OldVolume Then
MsgBox ("Volume has changed")
'Set the current volume as the "OldVolume"
OldVolume = GetVolume
End If
End Sub
I tried that code Megatron, but it didn't work for me, is that code suppose to trigger that msgbox if you change the
Total Volume or Wave Volume. The program kept thinking my volume was 0 for some reason.
Change "1" to the your DeviceID in this line
Retval = waveOutGetVolume(1, volume)
The volume control physically on the speakers cannot be accessed since it is local (eg it doesn't intercact with the computer)