Gene Posted October 12, 2005 Share Posted October 12, 2005 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... Link to comment Share on other sites More sharing options...
Valuater Posted October 12, 2005 Share Posted October 12, 2005 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) Link to comment Share on other sites More sharing options...
borisdieklinge Posted January 4, 2006 Share Posted January 4, 2006 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 Link to comment Share on other sites More sharing options...
seandisanti Posted January 4, 2006 Share Posted January 4, 2006 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 I3orisdieklingebeta is required for that script, the newest beta is on the downloads page Link to comment Share on other sites More sharing options...
GaryFrost Posted January 4, 2006 Share Posted January 4, 2006 using the latest beta you'll need to replace DllStructDelete ($p) with $p = "" SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
borisdieklinge Posted January 5, 2006 Share Posted January 5, 2006 can you specify a little bit more how to use the script, how can i get the variable of the volume? thx I3orisdieklinge Link to comment Share on other sites More sharing options...
GaryFrost Posted January 6, 2006 Share Posted January 6, 2006 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. Link to comment Share on other sites More sharing options...
Bert Posted September 17, 2007 Share Posted September 17, 2007 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 The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
weaponx Posted September 17, 2007 Share Posted September 17, 2007 Works for me dude. I'm using 3.2.8.1. Remember, this is returning the volume level for Wave Out, not Master Volume! Link to comment Share on other sites More sharing options...
GaryFrost Posted September 17, 2007 Share Posted September 17, 2007 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 100http://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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now