Sign in to follow this  
Followers 0
Maffe811

individual program volume controll

15 posts in this topic

Is this possible through AutoIt?

Cause when i play music with my speakers i would like grooveshark to be at 100% but games and other stuff to be at 20%-40%

And then if my friends call on skype i would plug in my headphones and set games to 80%, skype to 100% and music to 10%-20%

I searched around but didn't find much.

Any suggestions ?


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites



I imagine you would have to code each individual app to altear its volume

then code some preset functions to alter them.

Unless that is, you know of a way to manually do this through just windows.

Hmm, there is this Speaker icon, and if i click that there is a thing called mixer... But... Do i have to slide te sliders to slide the volume up and down?

Is there a way to _VolumeMixerSet($Program, $Volume) ?

This is what i would like to end up with ^

I just feel that since im doing this quite often makes it a great candidate for being automated to a button press.


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

What verison OS are you using?


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Win 7 x64


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

Doesn't Vista+ already have support for setting volume level on a per application bases. Skype for example would added to the volume mixer. If so you could try an automate that. I seem to remember a function that could be used to set the master volume level. If such a function exists pherhaps you could study it and find a way.


Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

Also, if a skypecall is accepted or made, skype turns down other sources of sound.

So it can't be that hard to do this!

Ill see what i can figure out.


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

I just noticed that the volume on steam hasn't changed for the last 3 reboots.

Which mean that the voulme level must be saved somewhere!

Right ? ...


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

The function I was thinking of before is:

SoundSetWaveVolume(100)

This is from the help file:

Remarks

This controls the Wave volume, not the master volume control. Also, a value of Zero does not set mute status.

On Windows Vista, there is no system-wide wave volume. This function only changes the wave volume for the script. It can not be used to change the wave volume of other programs.

So it wouldn't be helpful to you, sorry.

Edited by Decipher

Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I haven't tried this program personally but it seems legit. http://www.reallyeffective.co.uk/archive...ws-sound-mixer-applet-has-been

Quote: Added – Application – Options – Five applications can now be specified in Other Hot Keys.

Tried this.

Did the quote thing.

Its only to open a program with a hotkey...

Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

The function I was thinking of before is:

SoundSetWaveVolume(100)

This is from the help file:

Remarks

This controls the Wave volume, not the master volume control. Also, a value of Zero does not set mute status.

On Windows Vista, there is no system-wide wave volume. This function only changes the wave volume for the script. It can not be used to change the wave volume of other programs.

So it wouldn't be helpful to you, sorry.

Anyone who can rewrite this to

SoundSetWaveVolume($Volume, $ProgramHandle)

?


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

"winmm.dll" contains the functiontionallity that your looking for. Please verify that your system has this DLL and its version.

Look at this UDF designed for XP:

I'm particularly interested in these functions:

Func _SetMixerVolume($MixerDevice, $percent)
;default mixer is always 0 (so far) which is last audio device installed or prefered deviced selected by user
SetExtended(10)
$curmixer = 0
Const $MM_MIXM_CONTROL_CHANGE = 0x3D1
Const $CALLBACK_WINDOW = 0x10000
OpenAllMixers($mixers)
If @error Then Exit
$hmxobj = MixerOpen($curmixer, 0, $MM_MIXM_CONTROL_CHANGE, BitOR($CALLBACK_WINDOW, $MIXER_OBJECTF_MIXER))
GetMXWaveoutID($mixers, $curmixer, $MixerDevice)
_SetVolume($mixers, $curmixer, $percent)
MixerClose($hmxobj)
CloseAllMixers($mixers)
SetExtended(1)
Return(@extended)
EndFunc   ;==>_SetMixerVolume
Func OpenAllMixers(ByRef $mixers)
    Local $i, $mxnumdevs, $hmxobj
    $mxnumdevs = mixerGetNumDevs()
    If $mxnumdevs Then
        ReDim $mixers[$mxnumdevs + 1][$AMIX_SIZEOF]
        For $i = 0 To $mxnumdevs - 1
            $hmxobj = MixerOpen($i, 0, 0, $MIXER_OBJECTF_MIXER)
            If @error Then
                SetError(1)
                Return False
            EndIf
            $mixers[$i][$MIX_HMXOBJ] = $hmxobj
        Next ;i
    EndIf
    $mixers[0][0] = $mxnumdevs
EndFunc   ;==>OpenAllMixers

;On ENtry: mixer id and flag(s) , if no id passed then the preffered id is used (0) ditto for flag
;on exit: mixer handle
Func MixerOpen($uMxid = 0, $hwnd = 0, $instance = 0, $fdwOpen = 0)
    Local $x, $h_struct
    $h_struct = DllStructCreate("udword") ;since a local will be deleted on exit of function
    If @error Then
        SetError(1)
        Return False
    EndIf
    $ret = DllCall("winmm.dll", "long", "mixerOpen", "ptr", DllStructGetPtr($h_struct), "int", $uMxid, "int", $hwnd, "int", $instance, "int", $fdwOpen)
    If Not @error Then
        If $ret[0] <> $MMSYSERR_NOERROR Then Return -1
        $x = DllStructGetData($h_struct, 1)
        Return $x
    EndIf
    SetError(1)
    Return False
EndFunc   ;==>MixerOpen

Func CloseAllMixers($mixers)
    Local $i, $cnt
    $cnt = $mixers[0][0]
    For $i = 0 To $cnt - 1
        MixerClose($mixers[$i][$MIX_HMXOBJ])
    Next ;i
EndFunc   ;==>CloseAllMixers

;On Entry: mixer handle
Func MixerClose($hmxobj)
    $ret = DllCall("winmm.dll", "long", "mixerClose", "long", $hmxobj)
    If Not @error Then Return True
    Return False
EndFunc   ;==>MixerClose

Func mixerGetNumDevs()
    $ret = DllCall("winmm.dll", "long", "mixerGetNumDevs")
    If Not @error Then Return $ret[0]
    SetError(1)
    Return False
EndFunc   ;==>mixerGetNumDevs

OpenAllMixers() seems to return an array of mixers. You should be able to set them individually. One good question here is how to identify the mixer that you want the volume level to be set.

Other Info:

Volume Mixer: %windir%System32SndVol.exe -r 49490633

Waveform Audio Reference

Another Utility: http://blog.nirsoft.net/2011/02/25/how-to-control-the-volume-level-of-specific-application-from-command-line-on-windows-72008vista/

Download Page: http://www.nirsoft.net/utils/nircmd.html

Download Links:

NirCmd.zip

NirCmd-x64.zip

Edited by Decipher

Spoiler

censored.jpg

 

Share this post


Link to post
Share on other sites

;===============================================================================
;
; Internal Functions
;
;===============================================================================

That ^ but ill look into it..


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

With some will and research those internal functions from the XP Audio UDF should allow you to set the volume per application from AutoIt. If it was easily done and didn't require much thought then it usually wasn't worth doing in my experience. Experiment with using DllCall in AutoIt and you'll learn for the next time you encounter a problem that requires it. Honestly, I've not actually implemented such code in a script myself but I'm sure you can figure it out. I'll help you if I can. ;)


Spoiler

censored.jpg

 

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