Play/Pause/Stop geht nicht.

  • Guten Morgen.

    Kann mir jemand sagen warum die Play/Pause/Stop funktion nicht geht? Das Fileopen geht aber der rest nicht.

    Hier mein Code:

    Spoiler anzeigen
    [autoit]


    #cs ============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Author: Slash (Martin P)
    Script: iFlow Music Player

    [/autoit] [autoit][/autoit] [autoit]

    #ce ============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    #NoTrayIcon
    #include <GDIPlus.au3>
    #include <File.au3>
    #include <array.au3>
    #include <WindowsConstants.au3>
    #include <GuiConstantsEx.au3>
    #include <extprop.au3>
    #include <Sound.au3>
    #include <StaticConstants.au3>
    #include <GuiSlider.au3>
    #include <GuiToolTip.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $dll=DllOpen("user32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $AC_SRC_ALPHA = 1
    Global $ImageDir = @ScriptDir & "\data\"

    [/autoit] [autoit][/autoit] [autoit]

    ; Load PNG file as GDI bitmap
    _GDIPlus_Startup()
    $pngSrc = @ScriptDir & "\data\iflowbg.png"
    $hImage = _GDIPlus_ImageLoadFromFile($pngSrc)

    [/autoit] [autoit][/autoit] [autoit]

    ; Extract image width and height from PNG
    $width = _GDIPlus_ImageGetWidth($hImage)
    $height = _GDIPlus_ImageGetHeight($hImage)

    [/autoit] [autoit][/autoit] [autoit]

    ;Hauptfenster
    $GUI = GUICreate("iFlow Music Player", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
    SetBitmap($GUI, $hImage, 0)
    GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To 255 Step 5
    SetBitmap($GUI, $hImage, $i)
    Next
    ;Ende Hauptfenster

    [/autoit] [autoit][/autoit] [autoit]

    ;Keine Ahnung für was das ist??
    $GUI1 = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)
    GUICtrlCreatePic($ImageDir & "grey.gif", 0, 0, $width, $height)
    GUICtrlSetState(-1, $GUI_DISABLE)
    ;Ende Keine Ahnung für was das ist??

    [/autoit] [autoit][/autoit] [autoit]

    ;Fenster Titel
    GUICtrlCreateLabel("iFlow Music Player", 233, 16, 100, 32)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)
    ;Ende Fenster Titel

    [/autoit] [autoit][/autoit] [autoit]

    ;Close Button
    $hImageclose = _GDIPlus_ImageLoadFromFile("data\close.png")
    $hImageclose1 = _GDIPlus_ImageLoadFromFile("data\closehover.png")
    $hImageclose2 = _GDIPlus_ImageLoadFromFile("data\closehover.png")

    [/autoit] [autoit][/autoit] [autoit]

    $Close = GUICreate("Close", 0, 0, 488,13,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)
    SetBitmap($Close,$hImageclose,255)
    GUISetState()
    ;Ende Close Button

    [/autoit] [autoit][/autoit] [autoit]

    ;Minimier Button
    $hImagemin = _GDIPlus_ImageLoadFromFile("data\min.png")
    $hImagemin1 = _GDIPlus_ImageLoadFromFile("data\minhover.png")
    $hImagemin2 = _GDIPlus_ImageLoadFromFile("data\minhover.png")

    [/autoit] [autoit][/autoit] [autoit]

    $Min = GUICreate("Minimieren", 0, 0, 469,13,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)
    SetBitmap($Min,$hImagemin,255)
    GUISetState()
    ;Ende Minimier Button

    [/autoit] [autoit][/autoit] [autoit]

    ;Play Button
    $hImageplay = _GDIPlus_ImageLoadFromFile("data\play.png")
    $hImageplay1 = _GDIPlus_ImageLoadFromFile("data\playhover.png")
    $hImageplay2 = _GDIPlus_ImageLoadFromFile("data\playhover.png")

    [/autoit] [autoit][/autoit] [autoit]

    $Play = GUICreate("Play", 0, 0, 20,305,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)
    SetBitmap($Play,$hImageplay,255)
    GUISetState()
    ;Ende Play Button

    [/autoit] [autoit][/autoit] [autoit]

    ;Pause Button
    $hImagepause = _GDIPlus_ImageLoadFromFile("data\pause.png")
    $hImagepause1 = _GDIPlus_ImageLoadFromFile("data\pausehover.png")
    $hImagepause2 = _GDIPlus_ImageLoadFromFile("data\pausehover.png")

    [/autoit] [autoit][/autoit] [autoit]

    $Pause = GUICreate("Pause", 0, 0, 60,305,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)
    SetBitmap($Pause,$hImagepause,255)
    GUISetState()
    ;Ende Pause Button

    [/autoit] [autoit][/autoit] [autoit]

    ;Stop Button
    $hImagestop = _GDIPlus_ImageLoadFromFile("data\stop.png")
    $hImagestop1 = _GDIPlus_ImageLoadFromFile("data\stophover.png")
    $hImagestop2 = _GDIPlus_ImageLoadFromFile("data\stophover.png")

    [/autoit] [autoit][/autoit] [autoit]

    $Stop = GUICreate("Stop", 0, 0, 100,305,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)
    SetBitmap($Stop,$hImagestop,255)
    GUISetState()
    ;Ende Stop Button

    [/autoit] [autoit][/autoit] [autoit]

    ;Open Button
    $hImageopen = _GDIPlus_ImageLoadFromFile("data\open.png")
    $hImageopen1 = _GDIPlus_ImageLoadFromFile("data\openhover.png")
    $hImageopen2 = _GDIPlus_ImageLoadFromFile("data\openhover.png")

    [/autoit] [autoit][/autoit] [autoit]

    $Open = GUICreate("Open", 0, 0, 460,305,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)
    SetBitmap($Open,$hImageopen,255)
    GUISetState()
    ;Ende Open Button

    [/autoit] [autoit][/autoit] [autoit]

    ;Volume Button
    $hImagevolume = _GDIPlus_ImageLoadFromFile("data\volume.png")
    $hImagevolume1 = _GDIPlus_ImageLoadFromFile("data\volumehover.png")
    $hImagevolume2 = _GDIPlus_ImageLoadFromFile("data\volumemute.png")

    [/autoit] [autoit][/autoit] [autoit]

    $VolumeBTN = GUICreate("Volume", 0, 0, 390,305,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)
    SetBitmap($VolumeBTN,$hImagevolume,255)
    GUISetState()
    ;Ende Volume Button

    [/autoit] [autoit][/autoit] [autoit]

    ;Volume Button
    $hImagevolumepopup = _GDIPlus_ImageLoadFromFile("data\volumepopup.png")
    $hImagevolumepopup1 = _GDIPlus_ImageLoadFromFile("data\volumepopuphover.png")
    $hImagevolumepopup2 = _GDIPlus_ImageLoadFromFile("data\volumepopuphover.png")

    [/autoit] [autoit][/autoit] [autoit]

    $VolumeBTNPopup = GUICreate("Volume", 0, 0, 415,305,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$GUI)
    SetBitmap($VolumeBTNPopup,$hImagevolumepopup,255)
    GUISetState()
    ;Ende Volume Button

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    btnclose($Close,$hImageclose,$hImageclose1,$hImageclose2)
    btnmin($Min,$hImagemin,$hImagemin1,$hImagemin2)
    btnplay($Play,$hImageplay,$hImageplay1,$hImageplay2)
    btnpause($Pause,$hImagepause,$hImagepause1,$hImagepause2)
    btnstop($Stop,$hImagestop,$hImagestop1,$hImagestop2)
    btnopen($Open,$hImageopen,$hImageopen1,$hImageopen2)
    btnvolume($VolumeBTN,$hImagevolume,$hImagevolume1,$hImagevolume2)
    btnvolumepopup($VolumeBTNPopup,$hImagevolumepopup,$hImagevolumepopup1,$hImagevolumepopup2)
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    GUIDelete($GUI)

    [/autoit] [autoit][/autoit] [autoit]

    ;Bild aufbauen
    For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImageclose, $i)
    Next
    For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImagemin, $i)
    Next
    For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImageplay, $i)
    Next
    For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImagepause, $i)
    Next
    For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImagestop, $i)
    Next
    For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImageopen, $i)
    Next
    For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImagevolume, $i)
    Next
    For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImagevolumepopup, $i)
    Next

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Release resources
    _WinAPI_DeleteObject($hImageclose)
    _WinAPI_DeleteObject($hImagemin)
    _WinAPI_DeleteObject($hImageplay)
    _WinAPI_DeleteObject($hImagepause)
    _WinAPI_DeleteObject($hImagestop)
    _WinAPI_DeleteObject($hImageopen)
    _WinAPI_DeleteObject($hImagevolume)
    _WinAPI_DeleteObject($hImagevolumepopup)
    _WinAPI_DeleteObject($hImage)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
    EndFunc ;==>WM_NCHITTEST

    [/autoit] [autoit][/autoit] [autoit]

    ;Minimier Button Hover
    func btnmin($guicanset,$anh1,$anh2,$anh3)
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    Do
    if event() then
    Do
    if hander()<>$guicanset then
    SetBitmap($guicanset,$anh1,255)
    Else
    SetBitmap($guicanset,$anh3,255)
    EndIf
    Until not event()
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    Exit
    EndIf
    EndIf
    Until hander()<>$guicanset
    SetBitmap($guicanset,$anh1,255)
    EndIf
    EndFunc
    ;Ende Minimier Button Hover

    [/autoit] [autoit][/autoit] [autoit]

    ;Close Button Hover
    func btnclose($guicanset,$anh1,$anh2,$anh3)
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    Do
    if event() then
    Do
    if hander()<>$guicanset then
    SetBitmap($guicanset,$anh1,255)
    Else
    SetBitmap($guicanset,$anh3,255)
    EndIf
    Until not event()
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    Exit
    EndIf
    EndIf
    Until hander()<>$guicanset
    SetBitmap($guicanset,$anh1,255)
    EndIf
    EndFunc
    ;Ende Close Button Hover

    [/autoit] [autoit][/autoit] [autoit]

    ;Play Button Hover
    func btnplay($guicanset,$anh1,$anh2,$anh3)
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    Do
    if event() then
    Do
    if hander()<>$guicanset then
    SetBitmap($guicanset,$anh1,255)
    Else
    SetBitmap($guicanset,$anh3,255)
    EndIf
    Until not event()
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    _SoundPlay($Song)
    EndIf
    EndIf
    Until hander()<>$guicanset
    SetBitmap($guicanset,$anh1,255)
    EndIf
    EndFunc
    ;Ende Play Button Hover

    [/autoit] [autoit][/autoit] [autoit]

    ;Pause Button Hover
    func btnpause($guicanset,$anh1,$anh2,$anh3)
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    Do
    if event() then
    Do
    if hander()<>$guicanset then
    SetBitmap($guicanset,$anh1,255)
    Else
    SetBitmap($guicanset,$anh3,255)
    EndIf
    Until not event()
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    _SoundPause($Song)
    EndIf
    EndIf
    Until hander()<>$guicanset
    SetBitmap($guicanset,$anh1,255)
    EndIf
    EndFunc
    ;Ende Pause Button Hover

    [/autoit] [autoit][/autoit] [autoit]

    ;Stop Button Hover
    func btnstop($guicanset,$anh1,$anh2,$anh3)
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    Do
    if event() then
    Do
    if hander()<>$guicanset then
    SetBitmap($guicanset,$anh1,255)
    Else
    SetBitmap($guicanset,$anh3,255)
    EndIf
    Until not event()
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    _SoundStop($Song)
    EndIf
    EndIf
    Until hander()<>$guicanset
    SetBitmap($guicanset,$anh1,255)
    EndIf
    EndFunc
    ;Ende Stop Button Hover

    [/autoit] [autoit][/autoit] [autoit]

    ;Open Button Hover
    func btnopen($guicanset,$anh1,$anh2,$anh3)
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    Do
    if event() then
    Do
    if hander()<>$guicanset then
    SetBitmap($guicanset,$anh1,255)
    Else
    SetBitmap($guicanset,$anh3,255)
    EndIf
    Until not event()
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    $Song = FileOpenDialog("Bitte Musik Datei auswählen", @DesktopDir & "", "Musik Dateien(*.mp3;*.wav;*.wma;)",1)
    _SoundPlay($Song)
    SoundSetWaveVolume(5)
    EndIf
    EndIf
    Until hander()<>$guicanset
    SetBitmap($guicanset,$anh1,255)
    EndIf
    EndFunc
    ;Ende Open Button Hover

    [/autoit] [autoit][/autoit] [autoit]

    ;Volume Button Hover
    func btnvolume($guicanset,$anh1,$anh2,$anh3)
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    Do
    if event() then
    Do
    if hander()<>$guicanset then
    SetBitmap($guicanset,$anh1,255)
    Else
    SetBitmap($guicanset,$anh3,255)
    EndIf
    Until not event()
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    SoundSetWaveVolume(0)
    EndIf
    EndIf
    Until hander()<>$guicanset
    SetBitmap($guicanset,$anh1,255)
    EndIf
    EndFunc
    ;Ende Volume Button Hover

    [/autoit] [autoit][/autoit] [autoit]

    ;VolumePopup Hover
    func btnvolumepopup($guicanset,$anh1,$anh2,$anh3)
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    Do
    if event() then
    Do
    if hander()<>$guicanset then
    SetBitmap($guicanset,$anh1,255)
    Else
    SetBitmap($guicanset,$anh3,255)
    EndIf
    Until not event()
    if hander()=$guicanset then
    SetBitmap($guicanset,$anh2,255)
    _CreateSliderGUI()
    EndIf
    EndIf
    Until hander()<>$guicanset
    SetBitmap($guicanset,$anh1,255)
    EndIf
    EndFunc
    ;Ende VolumePopup Button Hover

    [/autoit] [autoit][/autoit] [autoit]

    Func _CreateSliderGUI($Min = 0, $Max = 100, $GuiWidth = 200, $GuiHeight = 50)
    Local $MousePos = MouseGetPos()
    Local $Mouse[2]
    $Mouse[0] = $MousePos[0]
    $Mouse[1] = $MousePos[1]
    Local $sGUI = GUICreate("Slider GUI", $GuiWidth, $GuiHeight, $MousePos[0] - $GuiWidth/2, $MousePos[1] - $GuiHeight/2, $WS_POPUP)
    Local $sSlider = GUICtrlCreateSlider(0, 0, $GuiWidth, $GuiHeight)
    GUICtrlSetBkColor(-1, 0x333333)
    GUICtrlSetLimit(-1, $Max, $Min)
    GUISetState(@SW_SHOW)
    While (($MousePos[0] >= $Mouse[0] - $GuiWidth/2 And $MousePos[0] <= $Mouse[0] + $GuiWidth/2) And ($MousePos[1] >= $Mouse[1] - $GuiHeight/2 And $MousePos[1] <= $Mouse[1] + $GuiHeight/2))
    $MousePos = MouseGetPos()
    WEnd
    GUISetState(@SW_HIDE)
    Return GUICtrlRead($sSlider)
    EndFunc ;==>_CreateSliderGUI

    [/autoit] [autoit][/autoit] [autoit]

    ;Funktion für Transparentes GUI
    Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    [/autoit] [autoit][/autoit] [autoit]

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
    EndFunc
    ;Ende Funktion für Transparentes GUI

    [/autoit] [autoit][/autoit] [autoit]

    ;Funktion für Button Hover
    Func hander()
    Local $iRet = DllCall("user32.dll", "int", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1))
    If IsArray($iRet) Then Return HWnd($iRet[0])
    Return SetError(1, 0, 0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func event($sHexKey="01", $vDLL = $dll)
    Local $a_R = DllCall($vDLL, "short", "GetAsyncKeyState", "int", '0x' & $sHexKey)
    If @error Then Return SetError(@error, @extended, False)
    Return BitAND($a_R[0], 0x8000) <> 0
    EndFunc
    ;Ende Funktion für Button Hover

    [/autoit]
  • Wo deklerierst du denn die Variable $Song?
    Du rufst sie zwar auf aberr sie ist nirgendwo deklariert.

    Ich hab auch gerade mal getestet mit meinem "SONG". Die Gui wird nicht angezeigt, oder ist das nur bei mir?

  • Du hast etwas vergessen, siehe

    mfg autoBert

  • Hier werden nur Threads von Admins/Mods geclosed die den Forenregeln widersprechen.
    Du kannst das aber selbst machen, indem du deinen Eröffnungspost bearbeitest, dort den Präfix (nähe Überschrift) auf gelöst stellst und danach speicherst,

    mfg autoBert