Jump to content
Sign in to follow this  
billthecreator

Volume Control

Recommended Posts

billthecreator

I need help finishing this script. I want it to control volume, but i cant seem to get it right. Can somebody help me?

here's the script

#include <GuiConstants.au3>

GuiCreate("MyGUI", 393, 125,-1, -1)

$Slider_1 = GuiCtrlCreateSlider(20, 40, 360, 30)
GUICtrlSetLimit($Slider_1,100,0)
GUICtrlSetData($Slider_1,100);
$Label_2 = GuiCtrlCreateLabel("Volume Control", 30, 10, 140, 20)
$Close = GuiCtrlCreateButton("Close", 150, 90, 60, 20)
SoundSetWaveVolume(100)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $Close
        Exit
    EndSelect
WEnd
Exit

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Share this post


Link to post
Share on other sites
Valuater

maybe...

#include <GuiConstants.au3>

$Volume = _SoundGetWaveVolume()

GUICreate("MyGUI", 393, 125, -1, -1)

$Slider_1 = GUICtrlCreateSlider(20, 40, 360, 30)
GUICtrlSetLimit($Slider_1, 100, 0)
GUICtrlSetData($Slider_1, $Volume);
$Label_2 = GUICtrlCreateLabel("Volume Control", 30, 10, 140, 20)
$Close = GUICtrlCreateButton("Close", 150, 90, 60, 20)
SoundSetWaveVolume($Volume)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Slider_1
            SoundSetWaveVolume(GUICtrlRead($Slider_1))
            ToolTip(GUICtrlRead($Slider_1))
            Sleep(300)
            ToolTip("")
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Close
            Exit
    EndSelect

WEnd
Exit

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
    $Struct = 0
    Return $WaveVol
EndFunc   ;==>_SoundGetWaveVolume

function from gafrost

8)


NEWHeader1.png

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  

×