Zisly Posted May 1, 2008 Share Posted May 1, 2008 I'm trying to get my a slider so I can control the sound level, but it is not working expandcollapse popup$Volume = _SoundGetWaveVolume() #include <GUIConstants.au3> #Include <Sound.au3> Global $mAlias #region ### START Koda GUI section ### Form=Form1_2.kxf\Form1_2.kxf $Main = GUICreate("Z Player", 253, 125, 207, 128) $Pic1 = GUICtrlCreatePic("Data\1.bmp", -8, 0, 260, 124, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) GUICtrlSetState($Pic1, $GUI_DISABLE) $play = GUICtrlCreateButton("(Not allowed)", 88, 8, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\play.bmp", 0) $stop = GUICtrlCreateButton("(Not allowed)", 24, 40, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\Stop.bmp", 0) $open = GUICtrlCreateButton("(Not allowed)", 88, 72, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\Open.bmp", 0) $pause = GUICtrlCreateButton("(Not allowed)", 152, 40, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\Pause.bmp", 0) $Slider1 = GUICtrlCreateSlider(0, 104, 246, 17, BitOR($TBS_AUTOTICKS,$TBS_BOTH,$TBS_NOTICKS)) GUICtrlSetLimit($Slider1, 100, 0); GUICtrlSetData($Slider1, $Volume) SoundSetWaveVolume($Volume); GuiSetState() GUISetState(@SW_SHOW) #endregion ### START Koda GUI section ### Form=Form1_2.kxf\Form1_2.kxf $VolOld = GuiCtrlRead($Slider1) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE _SoundStop($mAlias) Exit Case $open Local $music = FileOpenDialog("Choose a file to play", @DesktopDir, "Mp3 Files (*.mp3)", 3) If Not @error Then _SoundStop($mAlias) $mAlias = _SoundOpen($music) _SoundPlay($mAlias) GUICtrlSetData($play, "Pause") Else MsgBox(1 ,"Error","File could not be loaded/played, please try with another file.") EndIf Case $play _SoundPlay($mAlias) Case $stop _SoundStop($mAlias) Case $pause _SoundPause($mAlias) If GuiCtrlRead($Slider1) <> $VolOld Then SoundSetWaveVolume(GUICtrlRead($Slider1)) $VolOld = GuiCtrlRead($Slider1) ToolTip(GUICtrlRead($Slider1)); EndIf $ggci = GUIGetCursorInfo($Main) If $ggci[2] = 0 Then ToolTip("") EndIf EndSwitch WEnd 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 Exit Very thankfull for answers Link to comment Share on other sites More sharing options...
Valuater Posted May 1, 2008 Share Posted May 1, 2008 Maybe... expandcollapse popup$Volume = _SoundGetWaveVolume() #include <GUIConstants.au3> #Include <Sound.au3> Global $mAlias #region ### START Koda GUI section ### Form=Form1_2.kxf\Form1_2.kxf $Main = GUICreate("Z Player", 253, 125, 207, 128) $Pic1 = GUICtrlCreatePic("Data\1.bmp", -8, 0, 260, 124, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) GUICtrlSetState($Pic1, $GUI_DISABLE) $play = GUICtrlCreateButton("(Not allowed)", 88, 8, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\play.bmp", 0) $stop = GUICtrlCreateButton("(Not allowed)", 24, 40, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\Stop.bmp", 0) $open = GUICtrlCreateButton("(Not allowed)", 88, 72, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\Open.bmp", 0) $pause = GUICtrlCreateButton("(Not allowed)", 152, 40, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\Pause.bmp", 0) $Slider1 = GUICtrlCreateSlider(0, 104, 246, 17, BitOR($TBS_AUTOTICKS, $TBS_BOTH, $TBS_NOTICKS)) GUICtrlSetLimit($Slider1, 100, 0); GUICtrlSetData($Slider1, $Volume) SoundSetWaveVolume($Volume); GUISetState() GUISetState(@SW_SHOW) #endregion ### START Koda GUI section ### Form=Form1_2.kxf\Form1_2.kxf While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE _SoundStop($mAlias) Exit Case $open Local $music = FileOpenDialog("Choose a file to play", @DesktopDir, "Mp3 Files (*.mp3)", 3) If Not @error Then _SoundStop($mAlias) $mAlias = _SoundOpen($music) _SoundPlay($mAlias) GUICtrlSetData($play, "Pause") Else MsgBox(1, "Error", "File could not be loaded/played, please try with another file.") EndIf Case $play _SoundPlay($mAlias) Case $stop _SoundStop($mAlias) Case $pause _SoundPause($mAlias) EndSwitch $Info = GUIGetCursorInfo() While $Info[2] = 1 And $Info[4] = $Slider1 SoundSetWaveVolume(GUICtrlRead($Slider1)) ToolTip(GUICtrlRead($Slider1)) Sleep(100) $Info = GUIGetCursorInfo() WEnd $ggci = GUIGetCursorInfo($Main) If $ggci[2] = 0 Then ToolTip("") EndIf WEnd 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 Exit 8) Link to comment Share on other sites More sharing options...
Zisly Posted May 1, 2008 Author Share Posted May 1, 2008 (edited) Thank you Valuater! Btw is it possible to change the skin of the slider? (it doesn't really look that good ) Edit: Nevermind I saw your signature, I will check it out Edited May 1, 2008 by Zisly Link to comment Share on other sites More sharing options...
Zisly Posted May 1, 2008 Author Share Posted May 1, 2008 Sorry for double. I'm getting an error when I click on some other windows exept for the player and the player crashes :S The error say it occurs on line 58 at$Info = GUIGetCursorInfo() While $Info[2] = 1 And $Info[4] = $Slider1 SoundSetWaveVolume(GUICtrlRead($Slider1)) ToolTip(GUICtrlRead($Slider1)) Sleep(100) $Info = GUIGetCursorInfo() WEnd The whole code: expandcollapse popup$Volume = _SoundGetWaveVolume() #include <GUIConstants.au3> #Include <Sound.au3> Global $mAlias #region ### START Koda GUI section ### Form=Form1_2.kxf\Form1_2.kxf $Main = GUICreate("Z Player", 230, 168, 209, 130) $Pic1 = GUICtrlCreatePic("Data\1.bmp", -8, 0, 237, 167, BitOR($SS_NOPREFIX,$SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUICtrlSetState($Pic1, $GUI_DISABLE) $play = GUICtrlCreateButton("(Not allowed)", 80, 16, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\play.bmp", 0) $stop = GUICtrlCreateButton("(Not allowed)", 16, 48, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\Stop.bmp", 0) $open = GUICtrlCreateButton("(Not allowed)", 80, 80, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\Open.bmp", 0) $pause = GUICtrlCreateButton("(Not allowed)", 144, 48, 67, 32, $BS_BITMAP) GUICtrlSetImage(-1, "Data\Pause.bmp", 0) $Slider1 = GUICtrlCreateSlider(8, 144, 217, 20, BitOR($TBS_AUTOTICKS,$TBS_BOTH,$TBS_NOTICKS), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE)) GUICtrlSetLimit($Slider1, 100, 0); GUICtrlSetData($Slider1, $Volume) SoundSetWaveVolume($Volume); GUISetState() $Group1 = GUICtrlCreateGroup("Volume", 8, 120, 217, 25, $BS_CENTER, $WS_EX_TRANSPARENT) GUICtrlSetFont(-1, 13, 800, 0, "MS LineDraw") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0x000000) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #endregion ### START Koda GUI section ### Form=Form1_2.kxf\Form1_2.kxf While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE _SoundStop($mAlias) Exit Case $open Local $music = FileOpenDialog("Choose a file to play", @DesktopDir, "Mp3 Files (*.mp3)", 3) If Not @error Then _SoundStop($mAlias) $mAlias = _SoundOpen($music) _SoundPlay($mAlias) GUICtrlSetData($play, "Pause") Else MsgBox(1, "Error", "File could not be loaded/played, please try with another file.") EndIf Case $play _SoundPlay($mAlias) Case $stop _SoundStop($mAlias) Case $pause _SoundPause($mAlias) EndSwitch $Info = GUIGetCursorInfo() While $Info[2] = 1 And $Info[4] = $Slider1 SoundSetWaveVolume(GUICtrlRead($Slider1)) ToolTip(GUICtrlRead($Slider1)) Sleep(100) $Info = GUIGetCursorInfo() WEnd $ggci = GUIGetCursorInfo($Main) If $ggci[2] = 0 Then ToolTip("") EndIf WEnd 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 Exit Link to comment Share on other sites More sharing options...
Valuater Posted May 1, 2008 Share Posted May 1, 2008 Maybe... While WinActive($Main) And $Info[2] = 1 And $Info[4] = $Slider1 SoundSetWaveVolume(GUICtrlRead($Slider1)) ToolTip(GUICtrlRead($Slider1)) Sleep(100) $Info = GUIGetCursorInfo() WEnd 8) Link to comment Share on other sites More sharing options...
Zisly Posted May 1, 2008 Author Share Posted May 1, 2008 Still doesn't work This just comes up when I click on another window. Link to comment Share on other sites More sharing options...
Valuater Posted May 1, 2008 Share Posted May 1, 2008 Sorry, Icant test your script.. all of this is "in the Blind" While IsArray($Info) And WinActive($Main) And $Info[2] = 1 And $Info[4] = $Slider1 SoundSetWaveVolume(GUICtrlRead($Slider1)) ToolTip(GUICtrlRead($Slider1)) Sleep(100) $Info = GUIGetCursorInfo() WEnd 8) Link to comment Share on other sites More sharing options...
Zisly Posted May 1, 2008 Author Share Posted May 1, 2008 Sorry, Icant test your script.. all of this is "in the Blind" While IsArray($Info) And WinActive($Main) And $Info[2] = 1 And $Info[4] = $Slider1 SoundSetWaveVolume(GUICtrlRead($Slider1)) ToolTip(GUICtrlRead($Slider1)) Sleep(100) $Info = GUIGetCursorInfo() WEnd 8)Now it works, thanks 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