Sign in to follow this  
Followers 0
Gene

Is there a way to determine a PC's sound volume setting?

10 posts in this topic

The program I'm working on sounds tones at certain points to alert users who may not be looking at the screen. I put in a slider and code to raise/lower the volume. I'd like to be able to set it back on exit to what it was on startup. So, does anyone know how to determine a PC's sound volume setting?

Gene


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites



You got lucky........... gafrost wrote this recently

Func _SoundGetWaveVolume()
    Local $WaveVol = -1, $p, $ret
    Const $MMSYSERR_NOERROR = 0
    $p = DllStructCreate ("dword")
    If @error Then
        SetError(2)
        Return -2
    EndIf
    $ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p))
    If ($ret[0] == $MMSYSERR_NOERROR) Then
        $WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1), 8), 4)) / 0xFFFF * 100)
    Else
        SetError(1)
    EndIf
    DllStructDelete ($p)
    Return $WaveVol
EndFunc ;==>_SoundGetWaveVolume

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

can you tell me how it works? i always get error messages

>Running AU3Check...C:\Programme\AutoIt3\SciTe\Defs\Production\Au3Check\au3check.dat

C:\Programme\AutoIt3\Include\sound.au3(7,34) : ERROR: DllStructCreate(): undefined function.

$p = DllStructCreate ("dword")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Programme\AutoIt3\Include\sound.au3(12,100) : ERROR: DllStructGetPtr(): undefined function.

$ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Programme\AutoIt3\Include\sound.au3(14,69) : ERROR: DllStructGetData(): undefined function.

$WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Programme\AutoIt3\Include\sound.au3(18,24) : ERROR: DllStructDelete(): undefined function.

DllStructDelete ($p)

~~~~~~~~~~~~~~~~~~~~~~~^

D:\Dateien\AutoIT\sound.au3(2,28) : ERROR: SoundGetWaveVolume9(): undefined function.

$ddd = SoundGetWaveVolume9()

~~~~~~~~~~~~~~~~~~~~~~~~~~~^

D:\Dateien\AutoIT\sound.au3 - 5 error(s), 0 warning(s)

>AU3Check Ended with Error(s).

>Exit code: 0 Time: 2.835

how do i can get the volume

like this?

#include <soundGetWaveVolume.au3>
$ddd = SoundGetWaveVolume()
MsgBox(0,"",$ddd)

thx for help

I3orisdieklinge

Share this post


Link to post
Share on other sites

can you tell me how it works? i always get error messages

>Running AU3Check...C:\Programme\AutoIt3\SciTe\Defs\Production\Au3Check\au3check.dat

C:\Programme\AutoIt3\Include\sound.au3(7,34) : ERROR: DllStructCreate(): undefined function.

$p = DllStructCreate ("dword")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Programme\AutoIt3\Include\sound.au3(12,100) : ERROR: DllStructGetPtr(): undefined function.

$ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Programme\AutoIt3\Include\sound.au3(14,69) : ERROR: DllStructGetData(): undefined function.

$WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Programme\AutoIt3\Include\sound.au3(18,24) : ERROR: DllStructDelete(): undefined function.

DllStructDelete ($p)

~~~~~~~~~~~~~~~~~~~~~~~^

D:\Dateien\AutoIT\sound.au3(2,28) : ERROR: SoundGetWaveVolume9(): undefined function.

$ddd = SoundGetWaveVolume9()

~~~~~~~~~~~~~~~~~~~~~~~~~~~^

D:\Dateien\AutoIT\sound.au3 - 5 error(s), 0 warning(s)

>AU3Check Ended with Error(s).

>Exit code: 0 Time: 2.835

how do i can get the volume

like this?

#include <soundGetWaveVolume.au3>
$ddd = SoundGetWaveVolume()
MsgBox(0,"",$ddd)

thx for help

I3orisdieklinge

beta is required for that script, the newest beta is on the downloads page

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

can you specify a little bit more how to use the script, how can i get the variable of the volume?

thx

I3orisdieklinge

Share this post


Link to post
Share on other sites

can you specify a little bit more how to use the script, how can i get the variable of the volume?

thx

I3orisdieklinge

$vol = _SoundGetWaveVolume()
MsgBox(0,"",$vol)

Func _SoundGetWaveVolume()
    Local $WaveVol = -1, $p, $ret
    Const $MMSYSERR_NOERROR = 0
    $p = DllStructCreate ("dword")
    If @error Then
        SetError(2)
        Return -2
    EndIf
    $ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p))
    If ($ret[0] == $MMSYSERR_NOERROR) Then
        $WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1), 8), 4)) / 0xFFFF * 100)
    Else
        SetError(1)
    EndIf
    $p = ""
    Return $WaveVol
EndFunc;==>_SoundGetWaveVolume

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Works for me dude. I'm using 3.2.8.1. Remember, this is returning the volume level for Wave Out, not Master Volume!

Share this post


Link to post
Share on other sites

Gary,

I tried it, and I get a return of 100. It doesn't matter if I turn the sound up or down, I get the same result of 100

http://www.autoitscript.com/forum/index.ph...st&p=263737


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0