Beispielscript!

  • Hallo!

    ich habe mir eben einen beispiel script aus der englischen hilfe datein geholt:

    #include <Sound.au3>
    ;open sound file
    $sound = _SoundOpen("D:\Dokumente und Einstellungen\Lenny\Eigene Dateien\Eigene Musik\soundtrack.wav", "Tod")
    If @error = 2 Then
    MsgBox(0, "Error", "The file does not exist")
    Exit
    ElseIf @error = 3 Then
    MsgBox(0, "Error", "The alias was invalid")
    Exit
    ElseIf @extended <> 0 Then
    $extended = @extended ;assign because @extended will be set after DllCall
    Else
    MsgBox(0, "Success", "The file opened successfully")
    EndIf
    sleep(10000)
    _SoundClose($sound)

    jetzt würde ich gerne wissen warum er nicht so funktionier wie beschrieben oder warum er überhaupt nicht funzt


    danke im vorraus karl

  • Hi erstmal,
    der macht nix da er einfach nur checkt ob ein error vor liegt und vorher dem soundfile ne ID zuweist. Ich hab ma ein bespiel geschrieben wie es funktioniert ;D

    [autoit]

    #include <Sound.au3>
    _SoundOpen( "FILEPFAD", "FILEID")
    _SoundPlay( "FILEID", 1) ; für skript wartet bis sound aus is 0 für nicht warten

    [/autoit]

    Ich hoff das hilft dir weiter. :tongue:

    mfg Psycho

  • Hallo!
    Ja das hat mir geholfen danke!

    könnte man

    das hier

    _SoundOpen( "D:\Dokumente und Einstellungen\Lenny\Eigene Dateien\Eigene Musik\Sugarplum Fairy - Sweet Jackie.wav", "bla")
    _SoundPlay( "bla", 0)

    mit einem

    FileOpenDialog('','','wav-dat (*.wav)', 1)

    irgent wie kombinieren?

    danke karl

  • klar kann man das

    [autoit]

    $file = FileOpenDialog('','','wav-dat (*.wav)', 1)
    _SoundOpen($file, "bla")
    _SoundPlay("bla", 0)

    [/autoit]
  • aha danke ihr seit echt super!
    das hier ist mein script

    #cs ----------------------------------------------------------------------------

    AutoIt Version: 3.2.4.9
    Author: myName

    Script Function:
    Template AutoIt script.

    #ce ----------------------------------------------------------------------------

    ; Script Start - Add your code below here
    #NoTrayIcon
    #include <Date.au3>
    #include <GUIConstants.au3>
    #include <Sound.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Player", 636, 124, 197, 126, BitOR($WS_CAPTION,$WS_BORDER,$WS_CLIPSIBLINGS))
    $Button1 = GUICtrlCreateButton("RePlay", 368, 20, 65, 33, 0)
    $Pausebutton = GUICtrlCreateButton("&Pause", 432, 20, 65, 33, 0)
    $Button3 = GUICtrlCreateButton("&Next", 496, 20, 65, 33, 0)
    $Button4 = GUICtrlCreateButton("&Open", 560, 20, 65, 33, 0)
    $Button5 = GUICtrlCreateButton("EXIT", 24, 20, 41, 25, 0)
    $Volume = GUICtrlCreateSlider(0, 100, 640, 25)
    GUICtrlSetData(-1, 50)
    GUISetCursor (3)
    GUISetBkColor(0x000000)

    $Input1 = GUICtrlCreateInput("Notizen:", 88, 16, 249, 57)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    Dim $soundst = 0
    IF $soundst = 0 Then
    SoundPlay($sound)
    Else
    If $soundst = 1 Then
    MsgBox(64, "Error", "Keine Datei geöffnet!")
    EndIf
    EndIf

    Case $Pausebutton
    MsgBox(0,'',"Lied angehalten!" & _SoundPause($sound))
    Case $Button4
    $sound = FileOpenDialog('','','Mp3-Files (*.mp3;*.wav)', 1)
    If @error = 2 Then
    MsgBox(0, "Error", "The file does not exist")
    Exit
    ElseIf @error = 3 Then
    MsgBox(0, "Error", "The alias was invalid")
    Exit
    ElseIf @extended <> 0 Then
    $extended = @extended
    $errorstring = DllCall("winmm.dll","int","mciGetErrorStringA","str",$extended,"str","","int",65534,"hwnd",0)
    MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & $errorstring[2] & @CRLF & "Please Note: The sound may still play correctly.")
    Else
    MsgBox(0,'',"Datei erfolgreich geöffnet!")
    EndIf
    _SoundOpen($sound, "bla")
    _SoundPlay("bla", 1)

    Case $Volume
    SoundSetWaveVolume(100)
    Case $Button5
    WinClose("Player")
    MsgBox(0,'',"The time is:" & _NowTime())

    EndSwitch
    SoundSetWaveVolume(GUICtrlRead($Volume))
    WEnd


    irgentwie hängt der sich immer auf wenn ich irgentwas klicken möchte!
    könnt ihr mich vllt helfen?

    danke karl

    Einmal editiert, zuletzt von KARLderNOOB (18. August 2007 um 14:41)

  • Hast du vielleicht sowas wie ein mp3 und wav player gemeint ich hab schnell ma sowas gebastelt :D

    Bitteschön

    [autoit]

    #include <Sound.au3>
    #include <GUIConstants.au3>

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

    GUICreate("Player", 250, 50)
    $b1 = GUICtrlCreateButton("Song Wählen", 10, 10, 100)
    $b2 = GUICtrlCreateButton("Song Stop",130, 10,100)
    GUISetState()

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

    While 1 = 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg = $b1
    Player()
    Case $msg = $b2
    End()
    EndSelect
    WEnd

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

    Func Player()
    Global $message = "Bitte File Wählen"
    Global $var = FileOpenDialog($message,"\", "Mp3 / Wav (*.mp3;*.wav)", 1)
    If @error Then
    MsgBox(4096,"","No File(s) chosen")
    Else
    $var = StringReplace($var, "|", @CRLF)
    _SoundOpen( $var, $var)
    _SoundPlay( $var, 0) ; für skript wartet bis sound aus is 0 für nicht warten
    EndIf
    EndFunc

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

    Func End()
    _SoundClose($var)
    EndFunc

    [/autoit]

    war zu spät ^^

    EDIT:
    du musst bei sound play die 1 zu ner 0 machen dann gehen die knöpfe aber dein puse knopf geht nich und die volumen reglung auch nich

    EDIT2:

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

    ; Script Start - Add your code below here
    #NoTrayIcon
    #include <Date.au3>
    #include <GUIConstants.au3>
    #include <Sound.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Player", 636, 124, 197, 126, BitOR($WS_CAPTION,$WS_BORDER,$WS_CLIPSIBLINGS))
    $Button1 = GUICtrlCreateButton("RePlay", 368, 20, 65, 33, 0)
    $Pausebutton = GUICtrlCreateButton("&Pause", 432, 20, 65, 33, 0)
    $Button3 = GUICtrlCreateButton("&Next", 496, 20, 65, 33, 0)
    $Button4 = GUICtrlCreateButton("&Open", 560, 20, 65, 33, 0)
    $Button5 = GUICtrlCreateButton("EXIT", 24, 20, 41, 25, 0)
    $Volume = GUICtrlCreateSlider(0, 100, 640, 25)
    GUICtrlSetData(-1, 50)
    GUISetCursor (3)
    GUISetBkColor(0x000000)
    $r = 0
    $l = 0
    $Input1 = GUICtrlCreateInput("Notizen:", 88, 16, 249, 57)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1 = 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
    Exit
    Case $nMsg = $Button1
    Dim $soundst = 0
    IF $soundst = 0 Then
    _SoundPlay($sound)
    Else
    If $soundst = 1 Then
    MsgBox(64, "Error", "Keine Datei geöffnet!")
    EndIf
    EndIf

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

    Case $nMsg = $Pausebutton
    If $r = 0 Then
    MsgBox(0,'',"Lied angehalten!")
    _SoundPause("bla")
    $r = 1
    Else
    MsgBox(0,'',"Lied wieder gestartet!")
    _SoundResume("bla")
    $r = 0
    EndIf

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

    Case $nMsg = $Button4
    $sound = FileOpenDialog('','','Mp3-Files (*.mp3;*.wav)', 1)
    If @error = 2 Then
    MsgBox(0, "Error", "The file does not exist")
    Exit
    ElseIf @error = 3 Then
    MsgBox(0, "Error", "The alias was invalid")
    Exit
    ElseIf @extended <> 0 Then
    $extended = @extended
    $errorstring = DllCall("winmm.dll","int","mciGetErrorStringA","str",$extended,"str","","int",65534,"hwnd",0)
    MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & $errorstring[2] & @CRLF & "Please Note: The sound may still play correctly.")
    Else
    MsgBox(0,'',"Datei erfolgreich geöffnet!")
    EndIf

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

    if $l = 1 Then
    _SoundClose("bla")
    $l = 0
    EndIf
    if $l = 0 Then
    _SoundOpen($sound, "bla")
    _SoundPlay("bla", 0)
    $l = 1
    EndIf

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

    Case $nMsg = $Volume
    SoundSetWaveVolume(100)
    Case $nMsg = $Button5
    WinClose("Player")
    MsgBox(0,'',"The time is:" & _NowTime())

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

    EndSelect
    SoundSetWaveVolume(GUICtrlRead($Volume))
    WEnd

    [/autoit]

    Ich hab mal dein Pauseknopf repariert und wenn man jetzt ein neues lied öffnet wird das alte gestoppt

    3 Mal editiert, zuletzt von BlackPsycho (18. August 2007 um 16:13)