• Hallo, ich habe ein kleines Programm geschrieben, um dauerhaft Musik im Hintergrund laufen zu lassen...
    Alle Informationen werden als ToolTip ausgegeben.
    Man gibt in der config.ini im Scriptverzeichnis den Pfad zum ordner mit den mp3's an
    Funktionen:
    Zeigt bei nächstem Titel den Namen an (Auch abstellbar in der config.ini), ebenfalls aufrufbar über strg+alt+i aufrufbar
    Zufallsfunktion (Ohne die möglichkeit, das ein Titel doppelt vorkommt!), standartgemäß von alleine an, in der options.ini umstellbar, und temporär über strg+alt+r verändernbar
    Quit funktion :D (strg+alt+q)
    Im Ordnerpfad für die mp3's können @ScriptDir und @UserProfileDir verwendet werden!!!

    Es kann allerdings nur mp3's abspielen

    Hier ist der code, wenn ihr was meiner anleitung nicht versteht, einfach nach-haken!

    Spoiler anzeigen
    [autoit]

    #include <File.au3>
    #include <Sound.au3>
    #include <Array.au3>
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;All Features wich you can enable/disable are shown here
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

    HotKeySet ("!^n", "nextSong") ;Press ctrl+alt+n for next song
    HotKeySet ("!^r", "rand") ;Press ctrl+alt+r to disable/enable random playing
    HotKeySet ("!^q", "quit") ;Press ctrl+alt+q to quit
    HotKeySet ("!^i", "info") ;Press ctrl+alt+i to get now playing filename
    $showTitle = IniRead (@ScriptDir & "\config.ini", "ops", "showSongTitle", True)
    ;;;; This program can only play .mp3's! (I think it can play other formats too, but if there e.g is a textfile in the folder the program will crash, if i don't just enable mp3's...
    $rndList = _ArrayCreate ("")
    $rand = IniRead (@ScriptDir & "\config.ini", "ops", "DefaultRandomState", True)
    $path = IniRead (@ScriptDir & "\config.ini", "ops", "path", @ScriptDir)
    If StringInStr ($path, "@ScriptDir") Then
    $splt = StringSplit ($path, "@ScriptDir")
    If $splt[1] == "" Then
    $splt[1] = @ScriptDir ;Replace @ScriptDir to the real scriptpath
    ElseIf $splt[1] <> "" Then
    $x = 0
    Do
    $x += 1
    Until $splt[$x] == ""
    $splt[$x] = @ScriptDir ;Replace @ScriptDir to the real scriptpath
    EndIf
    EndIf
    If StringInStr ($path, "@UserProfileDir") Then
    $splt = StringSplit ($path, "@UserProfileDir")
    If $splt[1] == "" Then
    $splt[1] = @UserProfileDir ;Replace @ScriptDir to the real scriptpath
    ElseIf $splt[1] <> "" Then
    $x = 0
    Do
    $x += 1
    Until $splt[$x] == ""
    $splt[$x] = @UserProfileDir ;Replace @ScriptDir to the real scriptpath
    EndIf
    EndIf

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

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;To here
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    While 1
    $lst = _FileListToArray ($path, "*.mp3")
    If Not IsArray ($lst) Then
    MsgBox (32, "Error: not files found!", "No supported files found in " & $path & "! Waiting for files.")
    Do
    Sleep (3000)
    $lst = _FileListToArray ($path, "*.mp3")
    Until IsArray ($lst)
    EndIf
    $i = 1
    Do
    If $rand = True And $lst[0] <> $rndList[0] Then
    Do
    $i = Random (1, $lst[0])
    $splt = StringSplit ($i, ".")
    $i = $splt[1]
    Until _ArraySearch ($rndList, $i) == -1
    _ArrayAdd ($rndList, $i)
    $rndList[0] = UBound ($rndList)
    ElseIf $lst[0] == $rndList[0] Then
    $rndList = 0
    $rndList = _ArrayCreate ("")
    EndIf
    $open = _SoundOpen ($path & "\" & $lst[$i])
    _SoundPlay ($open)
    ToolTip ("Now playing " & $lst[$i])
    If $showTitle == True Then $init = TimerInit ()
    $stop = False
    Do
    If $stop = True Then ExitLoop
    If $showTitle == True Then
    If TimerDiff ($init) >= 1500 Then ToolTip ("") ;Show 1,5 seconds the new title
    EndIf
    Until _SoundPos ($open) == _SoundLength ($open)
    $i += 1
    _SoundClose ($open)
    Until $i = -1 = $lst[0]
    WEnd
    Func nextSong ()
    _SoundStop ($open)
    _SoundClose ($open)
    $stop = True
    EndFunc
    FUNC RAND ()
    If $rand = True Then
    ToolTip ("Random off")
    $rand = False
    ElseIf $rand = False Then
    ToolTip ("Random on")
    $rand = True
    EndIf
    $init = TimerInit ()
    Do
    Sleep (100)
    Until TimerDiff ($init) >= 200 ;Show 0,2 seconds the random state
    ENDFUNC
    FUNC QUIT ()
    Exit
    ENDFUNC
    FUNC INFO ()
    ToolTip ($lst[$i])
    $init = TimerInit ()
    Do
    Sleep (100)
    Until TimerDiff ($init) >= 1500 ; Show 1,5 seconds the title
    ENDFUNC

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

    ;Made by Das Schwert

    [/autoit]


    EDIT:
    Ihr könnt es zum Beispiel in den Autostart schieben...

    Theorie ist wenn man weiß wie's geht, aber nichts klappt.
    Praxis ist wenn's klappt aber man weiß nicht weiso.

    Bei Microsoft sind Theorie und Praxis vereint: Nichts klappt und keiner weiß wieso ;)

    Einmal editiert, zuletzt von Das Schwert (3. Dezember 2009 um 20:56)

  • Hab den code nochmal (Etwas) verbessert...
    Ist jetzt zwar 192 Zeilen länger (304 zeilen), aber hat viele neue Funktionen und n GUI...

    Der neue Code:

    Spoiler anzeigen
    [autoit]

    #include <File.au3>
    #include <Sound.au3>
    #include <Array.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <TabConstants.au3>
    #include <WindowsConstants.au3>
    $isplayed = False
    If $CMDLINE[0] <> 0 Then
    If $CMDLINE[1] == "restart" Then
    $thissong = IniRead (@ScriptDir & "\config.ini", "save", "lastSong", "error")
    IniDelete (@ScriptDir & "\config.ini", "save", "lastSong")
    If $thissong = "error" Then $CMDLINE[1] = ""
    EndIf
    EndIf
    $getsong = False
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;All Features wich you can enable/disable are shown here
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

    HotKeySet ("!^n", "nextSong") ;Press ctrl+alt+n for next song
    HotKeySet ("!^r", "rand") ;Press ctrl+alt+r to disable/enable random playing
    HotKeySet ("!^q", "quit") ;Press ctrl+alt+q to quit
    HotKeySet ("!^i", "info") ;Press ctrl+alt+i to get now playing filename
    HotKeySet ("!^g", "gui") ;Press ctrl+alt+g for GUI (A config etc. window)
    $showTitle = IniRead (@ScriptDir & "\config.ini", "ops", "showSongTitle", True)
    ;If $showTitle = "True" Then $showTitle = True
    ;@If $showTitle = "False" Then $showTitle = False
    ;;;; This program can only play .mp3's! (I think it can play other formats too, but if there e.g is a textfile in the folder the program will crash, if i don't just enable mp3's...
    $rndList = _ArrayCreate ("")
    $rand = IniRead (@ScriptDir & "\config.ini", "ops", "DefaultRandomState", True)
    $path = IniRead (@ScriptDir & "\config.ini", "ops", "path", @ScriptDir)
    If StringInStr ($path, "@ScriptDir") Then
    $splt = StringSplit ($path, "@ScriptDir")
    If $splt[1] == "" Then
    $splt[1] = @ScriptDir ;Replace @ScriptDir to the real scriptpath
    ElseIf $splt[1] <> "" Then
    $x = 0
    Do
    $x += 1
    Until $splt[$x] == ""
    $splt[$x] = @ScriptDir ;Replace @ScriptDir to the real scriptpath
    EndIf
    EndIf
    If StringInStr ($path, "@UserProfileDir") Then
    $splt = StringSplit ($path, "@UserProfileDir")
    If $splt[1] == "" Then
    $splt[1] = @UserProfileDir ;Replace @ScriptDir to the real scriptpath
    ElseIf $splt[1] <> "" Then
    $x = 0
    Do
    $x += 1
    Until $splt[$x] == ""
    $splt[$x] = @UserProfileDir ;Replace @ScriptDir to the real scriptpath
    EndIf
    EndIf

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

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;To here
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    While 1
    $lst = _FileListToArray ($path, "*.mp3")
    If Not IsArray ($lst) Then
    MsgBox (32, "Error: not files found!", "No supported files found in " & $path & "! Waiting for files.")
    Do
    Sleep (3000)
    $lst = _FileListToArray ($path, "*.mp3")
    Until IsArray ($lst)
    EndIf
    $i = 1
    Do
    $getsong = False
    $getsong = IniRead (@ScriptDir & "\config.ini", "saves", "getSong", False)
    IniDelete (@ScriptDir & "\config.ini", "saves", "getSong")
    If $rand = True And $lst[0] <> $rndList[0] And $getsong = "False" Then
    Do
    $i = Random (1, $lst[0])
    $splt = StringSplit ($i, ".")
    $i = $splt[1]
    Until _ArraySearch ($rndList, $i) == -1
    _ArrayAdd ($rndList, $i)
    $rndList[0] = UBound ($rndList)
    ElseIf $lst[0] == $rndList[0] Then
    $rndList = 0
    $rndList = _ArrayCreate ("")
    EndIf
    If $getsong = "False" Then
    $open = _SoundOpen ($path & "\" & $lst[$i])
    EndIf
    _SoundPlay ($open)
    If $CMDLINE[0] <> 0 Then
    If $isplayed = False Then
    If $CMDLINE[1] == "restart" Then
    $open = _SoundOpen ($path & "\" & $thissong)
    $isplayed = True
    EndIf
    EndIf
    EndIf
    If $showTitle == True Then
    If $getsong = "False" Then ToolTip ("Now playing " & $lst[$i])
    If $getsong = "True" Then
    ToolTip ("Now playing " & IniRead (@ScriptDir & "\config.ini", "saves", "song", "[Error!]"))
    IniDelete (@ScriptDir & "\config.ini", "saves", "song")
    EndIf
    EndIf
    IniDelete (@ScriptDir & "\config.ini", "saves", "song")
    If $showTitle == True Then $init = TimerInit ()
    $stop = False
    Do
    If $stop = True Then ExitLoop
    If $showTitle == True Then
    If TimerDiff ($init) >= 1500 Then ToolTip ("") ;Show 1,5 seconds the new title
    EndIf
    Until _SoundPos ($open) == _SoundLength ($open)
    $getsong = False
    $i += 1
    If $stop = False Then _SoundClose ($open)
    Until $i = -1 = $lst[0]
    WEnd
    Func nextSong ()
    _SoundStop ($open)
    _SoundClose ($open)
    $stop = True
    EndFunc
    FUNC RAND ()
    If $rand = True Then
    ToolTip ("Random off")
    $rand = False
    ElseIf $rand = False Then
    ToolTip ("Random on")
    $rand = True
    EndIf
    $init = TimerInit ()
    Do
    Sleep (100)
    Until TimerDiff ($init) >= 200 ;Show 0,2 seconds the random state
    ENDFUNC
    FUNC QUIT ()
    Exit
    ENDFUNC
    FUNC INFO ()
    ToolTip ($lst[$i])
    $init = TimerInit ()
    Do
    Sleep (100)
    Until TimerDiff ($init) >= 1500 ; Show 1,5 seconds the title
    ToolTip ("")
    ENDFUNC
    FUNC GUI ()
    ToolTip ("")
    #Region ### START Koda GUI section ### Form=C:\Users\----\Desktop\Music\Form1.kxf
    $Form1 = GUICreate("Backround muzik GUI", 625, 443, 192, 124)
    $tab = GUICtrlCreateTab(0, 0, 617, 441)
    GUICtrlSetFont(-1, 8, 400, 0, "Courier New")
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Now playing")
    $Label7 = GUICtrlCreateLabel("Song", 72, 32, 29, 17)
    $songlist = GUICtrlCreateList("", 72, 56, 201, 370)
    $Label8 = GUICtrlCreateLabel("Now playing", 224, 32, 62, 17)
    $PlayMarkedSong = GUICtrlCreateButton("Play marked song", 288, 400, 115, 25, $WS_GROUP)
    $timeplayed = GUICtrlCreateLabel("Time played:", 288, 344, 136, 17)
    $timeleft = GUICtrlCreateLabel("Song length:", 432, 344, 119, 17)
    $TabSheet2 = GUICtrlCreateTabItem("Ini Configuration")
    $auostartBackMuz = GUICtrlCreateCheckbox("Put Backround muzik into startup (Autorun Backround muzik on windows start)", 56, 120, 521, 17)
    $autornd = GUICtrlCreateCheckbox("Autostart random playing", 56, 56, 521, 17)
    If IniRead (@ScriptDir & "\config.ini", "ops", "DefaultRandomPlaying", True) == True Then GUICtrlSetState ($autornd, $GUI_CHECKED)
    $regstart = GUICtrlCreateRadio("Autostart over reg-entry", 88, 160, 481, 17)
    $folderstart = GUICtrlCreateRadio("Autostart over startupfolder", 88, 184, 505, 17)
    If RegRead ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik") Or RegRead ("HKLM\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik") Then
    GUICtrlSetState ($regstart, $GUI_CHECKED)
    GUICtrlSetState ($auostartBackMuz, $GUI_CHECKED)
    ElseIf FileExists (@StartupCommonDir & "\Background Muzik.lnk") Or FileExists (@StartupDir & "\Background Muzik.lnk") Then
    GUICtrlSetState ($folderstart, $GUI_CHECKED)
    GUICtrlSetState ($auostartBackMuz, $GUI_CHECKED)
    Else
    GUICtrlSetState ($regstart, $GUI_CHECKED)
    EndIf
    $everyone = GUICtrlCreateCheckbox("For everyone who uses this computer", 88, 208, 505, 17)
    $save = GUICtrlCreateButton("Save changes", 56, 360, 91, 25, $WS_GROUP)
    $restart = GUICtrlCreateButton("Restart program (Required for new mp3 path)", 152, 360, 267, 25, $WS_GROUP)
    $showTitelfield = GUICtrlCreateCheckbox("Show new songtitel if next song starts", 56, 264, 521, 17)
    If IniRead (@ScriptDir & "\config.ini", "ops", "showSongTitle", True) == True Then GUICtrlSetState ($showTitelfield, $GUI_CHECKED)
    $Label11 = GUICtrlCreateLabel("Folder with mp3's:", 8, 304, 88, 17)
    $folderpath = GUICtrlCreateInput("", 104, 304, 441, 21)
    GUICtrlSetData ($folderpath, IniRead (@ScriptDir & "\config.ini", "ops", "path", @ScriptDir))
    $changeFolder = GUICtrlCreateButton("Change", 544, 304, 67, 25, $WS_GROUP)
    $TabSheet3 = GUICtrlCreateTabItem("About")
    GUICtrlSetState(-1,$GUI_SHOW)
    $Label1 = GUICtrlCreateLabel("Backround muzik by Das Schwert (The Sword)", 32, 64, 225, 17)
    $Label2 = GUICtrlCreateLabel("For support etc send a mail to [email='schwertsoft@web.de'][/email].", 32, 80, 249, 17)
    $Label3 = GUICtrlCreateLabel("Homepage:", 32, 96, 59, 17)
    $HPLnk = GUICtrlCreateLabel("http://schwertsoft.ucoz.com", 96, 96, 138, 17)
    GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x0000FF)
    GUICtrlSetCursor (-1, 0)
    $Label5 = GUICtrlCreateLabel("(This page is german!)", 240, 96, 108, 17)
    $Label6 = GUICtrlCreateLabel("If you have any idea to make my progs better, then send it to me!", 32, 128, 309, 17)
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $c = 1
    $string = ""
    Do
    If $lst[$c] <> $lst[$i] Then
    $string &= $lst[$c] & "|"
    Else
    $string &= $lst[$c] & "------Playing...|"
    Endif
    $c += 1
    Until $c = $lst[0]
    $string &= $lst[$c]
    GUICtrlSetData ($songlist, $string)
    $init2 = TimerInit ()
    $last = 0
    While 1
    If TimerDiff ($init2) + 1000 >= $last Then
    $last = TimerDiff ($init2)
    $played = _SoundPos ($open)
    GUICtrlSetData ($timeplayed, $played)
    GUICtrlSetData ($timeleft, _SoundLength ($open))
    EndIf
    $msg = GUIGetMsg ()
    If $msg = -3 Then Exit
    If $msg = $PlayMarkedSong Then
    $song = GUICtrlRead ($songlist)
    $i = 1
    Do
    If $lst[$i] == $song Then
    ExitLoop
    EndIf
    $i += 1
    Until $lst[0] = $i -1
    _SoundStop ($open)
    _SoundClose ($open)
    ;$i -= 1
    $iniwrite = $lst[$i]
    $open = _SoundOpen ($path & "\" & $lst[$i])
    IniWrite (@ScriptDir & "\config.ini", "saves", "song", $iniwrite)
    $stop = True
    IniWrite (@ScriptDir & "\config.ini", "saves", "getSong", True)
    GUIDelete ()
    Return 0
    EndIf
    If $msg = $save Then
    RegDelete ("HKLM\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik")
    RegDelete ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik")
    FileDelete (@StartupCommonDir & "\Background Muzik.lnk")
    FileDelete (@StartupDir & "\Background Muzik.lnk")
    If GUICtrlRead ($showTitelfield) == $GUI_CHECKED Then
    IniWrite (@ScriptDir & "\config.ini", "ops", "showSongTitle", True)
    ElseIf GUICtrlRead ($showTitelfield) == $GUI_UNCHECKED Then
    IniWrite (@ScriptDir & "\config.ini", "ops", "showSongTitle", False)
    EndIf
    If GUICtrlRead ($autornd) == $GUI_CHECKED Then
    IniWrite (@ScriptDir & "\config.ini", "ops", "DefaultRandomPlaying", True)
    Else
    IniWrite (@ScriptDir & "\config.ini", "ops", "DefaultRandomPlaying", False)
    EndIf
    IniWrite (@ScriptDir & "\config.ini", "ops", "path", GUICtrlRead ($folderpath))
    If GUICtrlRead ($auostartBackMuz) == $GUI_CHECKED Then
    If GUICtrlRead ($everyone) == $GUI_CHECKED Then
    $users = "everyone"
    ElseIf GUICtrlRead ($everyone) == $GUI_UNCHECKED Then
    $user = "me"
    EndIf
    If GUICtrlRead ($regstart) == $GUI_CHECKED Then
    $startmethode = "reg"
    ElseIf GUICtrlRead ($folderstart) == $GUI_CHECKED Then
    $startmethode = "folder"
    EndIf
    If $startmethode = "reg" Then
    If $user == "me" Then
    RegWrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik", "REG_SZ", @ScriptFullPath)
    ElseIf $user == "everyone" Then
    RegWrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik", "REG_SZ", @ScriptFullPath)
    EndIf
    ElseIf $startmethode = "folder" Then
    If $user = "everyone" Then
    FileCreateShortcut (@ScriptFullPath, @StartupCommonDir & "\Background Muzik.lnk")
    ElseIf $user = "me" Then
    FileCreateShortcut (@ScriptFullPath, @StartupDir & "\Background Muzik.lnk")
    Else
    MsgBox (32, "Fatal error!", "Fatal error!")
    EndIf
    EndIf
    EndIf
    EndIf
    If $msg = $restart Then
    IniWrite (@ScriptDir & "\config.ini", "saves", "lastSong", $lst[$i])
    ShellExecute (@ScriptFullPath, "restart")
    Exit
    EndIf
    If $msg = $HPLnk Then
    $splt = StringSplit (RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", ""), '"')
    $browser = $splt[2]
    ShellExecute ($browser, "http://schwertsoft.ucoz.com")
    EndIf
    WEnd
    ENDFUNC
    ;Made by Das Schwert

    [/autoit]

    Theorie ist wenn man weiß wie's geht, aber nichts klappt.
    Praxis ist wenn's klappt aber man weiß nicht weiso.

    Bei Microsoft sind Theorie und Praxis vereint: Nichts klappt und keiner weiß wieso ;)

  • =>Bugs entfernt...
    ==>Nun läuft das manuelle auswählen von Lieder (über GUI) richtig.
    =>Ich habe eine bearbeitete (mit Kommentaren versehene) Version der config.ini als Spoiler dabei...

    Script

    Spoiler anzeigen
    [autoit]

    #include <File.au3>
    #include <Sound.au3>
    #include <Array.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <TabConstants.au3>
    #include <WindowsConstants.au3>
    If IniRead (@ScriptDir & "\config.ini", "ops", "path", "error") == "error" Then
    MsgBox (32, "Error!", "No path for mp3 files found in config.ini! Please set one!")
    $newpath = FileSelectFolder ("Path for mp3's", @DesktopDir)
    If @error Then Exit
    IniWrite (@ScriptDir & "\config.ini", "ops", "path", $newpath)
    EndIf
    $isplayed = False
    If $CMDLINE[0] <> 0 Then
    If $CMDLINE[1] == "restart" Then
    $thissong = IniRead (@ScriptDir & "\config.ini", "save", "lastSong", "error")
    IniDelete (@ScriptDir & "\config.ini", "save", "lastSong")
    If $thissong = "error" Then $CMDLINE[1] = ""
    EndIf
    EndIf
    $getsong = False
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;All Features wich you can enable/disable are shown here
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

    HotKeySet ("!^n", "nextSong") ;Press ctrl+alt+n for next song
    HotKeySet ("!^r", "rand") ;Press ctrl+alt+r to disable/enable random playing
    HotKeySet ("!^q", "quit") ;Press ctrl+alt+q to quit
    HotKeySet ("!^i", "info") ;Press ctrl+alt+i to get now playing filename
    HotKeySet ("!^g", "gui") ;Press ctrl+alt+g for GUI (A config etc. window)
    $showTitle = IniRead (@ScriptDir & "\config.ini", "ops", "showSongTitle", True)
    ;If $showTitle = "True" Then $showTitle = True
    ;@If $showTitle = "False" Then $showTitle = False
    ;;;; This program can only play .mp3's! (I think it can play other formats too, but if there e.g is a textfile in the folder the program will crash, if i don't just enable mp3's...
    $rndList = _ArrayCreate ("")
    $rand = IniRead (@ScriptDir & "\config.ini", "ops", "DefaultRandomState", True)
    $path = IniRead (@ScriptDir & "\config.ini", "ops", "path", @ScriptDir)
    If StringInStr ($path, "@ScriptDir") Then
    $splt = StringSplit ($path, "@ScriptDir")
    If $splt[1] == "" Then
    $splt[1] = @ScriptDir ;Replace @ScriptDir to the real scriptpath
    ElseIf $splt[1] <> "" Then
    $x = 0
    Do
    $x += 1
    Until $splt[$x] == ""
    $splt[$x] = @ScriptDir ;Replace @ScriptDir to the real scriptpath
    EndIf
    EndIf
    If StringInStr ($path, "@UserProfileDir") Then
    $splt = StringSplit ($path, "@UserProfileDir")
    If $splt[1] == "" Then
    $splt[1] = @UserProfileDir ;Replace @ScriptDir to the real scriptpath
    ElseIf $splt[1] <> "" Then
    $x = 0
    Do
    $x += 1
    Until $splt[$x] == ""
    $splt[$x] = @UserProfileDir ;Replace @ScriptDir to the real scriptpath
    EndIf
    EndIf

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

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;To here
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    While 1
    $lst = _FileListToArray ($path, "*.mp3")
    If Not IsArray ($lst) Then
    MsgBox (32, "Error: not files found!", "No supported files found in " & $path & "! Waiting for files.")
    Do
    Sleep (3000)
    $lst = _FileListToArray ($path, "*.mp3")
    Until IsArray ($lst)
    EndIf
    $i = 1
    Do
    $getsong = False
    $getsong = IniRead (@ScriptDir & "\config.ini", "saves", "getSong", "False")
    If $rand = True And $lst[0] <> $rndList[0] And $getsong = "False" Then
    Do
    $i = Random (1, $lst[0])
    $splt = StringSplit ($i, ".")
    $i = $splt[1]
    Until _ArraySearch ($rndList, $i) == -1
    _ArrayAdd ($rndList, $i)
    $rndList[0] = UBound ($rndList)
    ElseIf $lst[0] == $rndList[0] Then
    $rndList = 0
    $rndList = _ArrayCreate ("")
    EndIf
    If $getsong = "False" Then
    IniWrite (@ScriptDir & "\config.ini", "saves", "Song", $lst[$i])
    $open = _SoundOpen ($path & "\" & $lst[$i])
    EndIf
    _SoundPlay ($open)
    If $CMDLINE[0] <> 0 Then
    If $isplayed = False Then
    If $CMDLINE[1] == "restart" Then
    $open = _SoundOpen ($path & "\" & $thissong)
    $isplayed = True
    EndIf
    EndIf
    EndIf
    If $showTitle == True Then
    If $getsong = "False" Then ToolTip ("Now playing " & $lst[$i])
    If $getsong = "True" Then
    ToolTip ("Now playing " & IniRead (@ScriptDir & "\config.ini", "saves", "song", "[Error!]"))
    EndIf
    EndIf
    If $showTitle == True Then $init = TimerInit ()
    $stop = False
    Do
    If $stop = True Then ExitLoop
    Sleep (100)
    If $showTitle == True Then
    If TimerDiff ($init) >= 1500 Then ToolTip ("") ;Show 1,5 seconds the new title
    EndIf
    Until _SoundPos ($open) == _SoundLength ($open)
    IniDelete (@ScriptDir & "\config.ini", "saves", "getSong")
    $getsong = False
    $i += 1
    If $stop = False Then _SoundClose ($open)
    Until $i = -1 = $lst[0]
    WEnd
    Func nextSong ()
    _SoundStop ($open)
    _SoundClose ($open)
    $stop = True
    EndFunc
    FUNC RAND ()
    If $rand = True Then
    ToolTip ("Random off")
    $rand = False
    ElseIf $rand = False Then
    ToolTip ("Random on")
    $rand = True
    EndIf
    $init = TimerInit ()
    Do
    Sleep (100)
    Until TimerDiff ($init) >= 200 ;Show 0,2 seconds the random state
    ENDFUNC
    FUNC QUIT ()
    Exit
    ENDFUNC
    FUNC INFO ()
    ToolTip (IniRead (@ScriptDir & "\config.ini", "saves", "Song", "error"))
    $init = TimerInit ()
    Do
    Sleep (100)
    Until TimerDiff ($init) >= 1500 ; Show 1,5 seconds the title
    ToolTip ("")
    ENDFUNC
    FUNC GUI ()
    ToolTip ("")
    #Region ### START Koda GUI section ### Form=C:\Users\----\Desktop\Music\Form1.kxf
    $Form1 = GUICreate("Backround muzik GUI", 625, 443, 192, 124)
    $tab = GUICtrlCreateTab(0, 0, 617, 441)
    GUICtrlSetFont(-1, 8, 400, 0, "Courier New")
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Now playing")
    $Label7 = GUICtrlCreateLabel("Song", 72, 32, 29, 17)
    $songlist = GUICtrlCreateList("", 72, 56, 201, 370)
    $Label8 = GUICtrlCreateLabel("Now playing", 224, 32, 62, 17)
    $PlayMarkedSong = GUICtrlCreateButton("Play marked song", 288, 400, 115, 25, $WS_GROUP)
    $timeplayed = GUICtrlCreateLabel("Time played:", 288, 344, 136, 17)
    $timeleft = GUICtrlCreateLabel("Song length:", 432, 344, 119, 17)
    $TabSheet2 = GUICtrlCreateTabItem("Ini Configuration")
    $auostartBackMuz = GUICtrlCreateCheckbox("Put Backround muzik into startup (Autorun Backround muzik on windows start)", 56, 120, 521, 17)
    $autornd = GUICtrlCreateCheckbox("Autostart random playing", 56, 56, 521, 17)
    If IniRead (@ScriptDir & "\config.ini", "ops", "DefaultRandomPlaying", True) == True Then GUICtrlSetState ($autornd, $GUI_CHECKED)
    $regstart = GUICtrlCreateRadio("Autostart over reg-entry", 88, 160, 481, 17)
    $folderstart = GUICtrlCreateRadio("Autostart over startupfolder", 88, 184, 505, 17)
    If RegRead ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik") Or RegRead ("HKLM\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik") Then
    GUICtrlSetState ($regstart, $GUI_CHECKED)
    GUICtrlSetState ($auostartBackMuz, $GUI_CHECKED)
    ElseIf FileExists (@StartupCommonDir & "\Background Muzik.lnk") Or FileExists (@StartupDir & "\Background Muzik.lnk") Then
    GUICtrlSetState ($folderstart, $GUI_CHECKED)
    GUICtrlSetState ($auostartBackMuz, $GUI_CHECKED)
    Else
    GUICtrlSetState ($regstart, $GUI_CHECKED)
    EndIf
    $everyone = GUICtrlCreateCheckbox("For everyone who uses this computer", 88, 208, 505, 17)
    $save = GUICtrlCreateButton("Save changes", 56, 360, 91, 25, $WS_GROUP)
    $restart = GUICtrlCreateButton("Restart program (Required for new mp3 path)", 152, 360, 267, 25, $WS_GROUP)
    $showTitelfield = GUICtrlCreateCheckbox("Show new songtitel if next song starts", 56, 264, 521, 17)
    If IniRead (@ScriptDir & "\config.ini", "ops", "showSongTitle", True) == True Then GUICtrlSetState ($showTitelfield, $GUI_CHECKED)
    $Label11 = GUICtrlCreateLabel("Folder with mp3's:", 8, 304, 88, 17)
    $folderpath = GUICtrlCreateInput("", 104, 304, 441, 21)
    GUICtrlSetData ($folderpath, IniRead (@ScriptDir & "\config.ini", "ops", "path", @ScriptDir))
    $changeFolder = GUICtrlCreateButton("Change", 544, 304, 67, 25, $WS_GROUP)
    $TabSheet3 = GUICtrlCreateTabItem("About")
    GUICtrlSetState(-1,$GUI_SHOW)
    $Label1 = GUICtrlCreateLabel("Backround muzik by Das Schwert (The Sword)", 32, 64, 225, 17)
    $Label2 = GUICtrlCreateLabel("For support etc send a mail to [email='schwertsoft@web.de'][/email].", 32, 80, 249, 17)
    $Label3 = GUICtrlCreateLabel("Homepage:", 32, 96, 59, 17)
    $HPLnk = GUICtrlCreateLabel("http://schwertsoft.ucoz.com", 96, 96, 138, 17)
    GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x0000FF)
    GUICtrlSetCursor (-1, 0)
    $Label5 = GUICtrlCreateLabel("(This page is german!)", 240, 96, 108, 17)
    $Label6 = GUICtrlCreateLabel("If you have any idea to make my progs better, then send it to me!", 32, 128, 309, 17)
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $c = 1
    $string = ""
    Do
    If $lst[$c] <> $lst[$i] And $lst[$c] <> IniRead (@ScriptDir & "\config.ini", "saves", "Song", "error") Then
    $string &= $lst[$c] & "|"
    ElseIf $lst[$c] == IniRead (@ScriptDir & "\config.ini", "saves", "Song", "error") Then
    $string &= IniRead (@ScriptDir & "\config.ini", "saves", "Song", "error") & "------Playing...|"
    Endif
    $c += 1
    Until $c = $lst[0]
    $string &= $lst[$c]
    GUICtrlSetData ($songlist, $string)
    $init2 = TimerInit ()
    $last = 0
    While 1
    If TimerDiff ($init2) + 1000 >= $last Then
    $last = TimerDiff ($init2)
    $played = _SoundPos ($open)
    GUICtrlSetData ($timeplayed, $played)
    GUICtrlSetData ($timeleft, _SoundLength ($open))
    EndIf
    $msg = GUIGetMsg ()
    If $msg = -3 And (MsgBox (36, "Warning!", "If you close the window before klicking 'Save changes' all changes will be lost!") == 6) Then
    GUIDelete ()
    Return 0
    EndIf
    If $msg = $PlayMarkedSong Then
    $song = GUICtrlRead ($songlist)
    $i = 1
    Do
    If $lst[$i] == $song Then
    ExitLoop
    EndIf
    $i += 1
    Until $lst[0] = $i -1
    _SoundStop ($open)
    _SoundClose ($open)
    ;$i -= 1
    $iniwrite = $lst[$i]
    $open = _SoundOpen ($path & "\" & $lst[$i])
    IniWrite (@ScriptDir & "\config.ini", "saves", "song", $iniwrite)
    $stop = True
    IniWrite (@ScriptDir & "\config.ini", "saves", "getSong", "True")
    GUIDelete ()
    Return 0
    EndIf
    If $msg = $save Then
    RegDelete ("HKLM\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik")
    RegDelete ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik")
    FileDelete (@StartupCommonDir & "\Background Muzik.lnk")
    FileDelete (@StartupDir & "\Background Muzik.lnk")
    If GUICtrlRead ($showTitelfield) == $GUI_CHECKED Then
    IniWrite (@ScriptDir & "\config.ini", "ops", "showSongTitle", True)
    ElseIf GUICtrlRead ($showTitelfield) == $GUI_UNCHECKED Then
    IniWrite (@ScriptDir & "\config.ini", "ops", "showSongTitle", False)
    EndIf
    If GUICtrlRead ($autornd) == $GUI_CHECKED Then
    IniWrite (@ScriptDir & "\config.ini", "ops", "DefaultRandomPlaying", True)
    Else
    IniWrite (@ScriptDir & "\config.ini", "ops", "DefaultRandomPlaying", False)
    EndIf
    IniWrite (@ScriptDir & "\config.ini", "ops", "path", GUICtrlRead ($folderpath))
    If GUICtrlRead ($auostartBackMuz) == $GUI_CHECKED Then
    If GUICtrlRead ($everyone) == $GUI_CHECKED Then
    $users = "everyone"
    ElseIf GUICtrlRead ($everyone) == $GUI_UNCHECKED Then
    $user = "me"
    EndIf
    If GUICtrlRead ($regstart) == $GUI_CHECKED Then
    $startmethode = "reg"
    ElseIf GUICtrlRead ($folderstart) == $GUI_CHECKED Then
    $startmethode = "folder"
    EndIf
    If $startmethode = "reg" Then
    If $user == "me" Then
    RegWrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik", "REG_SZ", @ScriptFullPath)
    ElseIf $user == "everyone" Then
    RegWrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik", "REG_SZ", @ScriptFullPath)
    EndIf
    ElseIf $startmethode = "folder" Then
    If $user = "everyone" Then
    FileCreateShortcut (@ScriptFullPath, @StartupCommonDir & "\Background Muzik.lnk")
    ElseIf $user = "me" Then
    FileCreateShortcut (@ScriptFullPath, @StartupDir & "\Background Muzik.lnk")
    Else
    MsgBox (32, "Fatal error!", "Fatal error!")
    EndIf
    EndIf
    EndIf
    EndIf
    If $msg = $restart Then
    IniWrite (@ScriptDir & "\config.ini", "saves", "lastSong", $lst[$i])
    ShellExecute (@ScriptFullPath, "restart")
    Exit
    EndIf
    If $msg = $HPLnk Then
    $splt = StringSplit (RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", ""), '"')
    $browser = $splt[2]
    ShellExecute ($browser, "http://schwertsoft.ucoz.com")
    EndIf
    WEnd
    ENDFUNC
    FUNC ONAUTOITEXIT ()
    IniDelete (@ScriptDir & "\config.ini", "saves", "song")
    IniDelete (@ScriptDir & "\config.ini", "saves", "getSong")
    ENDFUNC ;Made by Das Schwert

    [/autoit]

    Ini

    Spoiler anzeigen
    [autoit]

    [saves]
    ==>
    ==>Don't touch this section! !!! It will be deleted when the program ends! Press CTRL+ALT+Q to exit BackMuz!
    ==>
    song=Lie to me.mp3
    getSong=True

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

    [ops]
    ==>
    ==>Here you can change options. Some options me only affect after an restart!
    ==>
    DefaultRandomPlaying=True
    ==>
    ==>Set to False if you want that it plays the songs from begin with a to begin with z
    ==>
    path=C:\Users\Keno\Desktop\Music
    ==>
    ==>Set the folder for the mp3's. Folder can contain other files no Subfolders supported. Will look how to do this.
    ==>
    showSongTitle=False
    ==>
    ==>If set to True it will show the new songtitle if a song finshes as ToolTip
    ==>

    [/autoit]


    EDIT: Eine test MsgBox entfernt, und nen Crash-bug gefixt

    Theorie ist wenn man weiß wie's geht, aber nichts klappt.
    Praxis ist wenn's klappt aber man weiß nicht weiso.

    Bei Microsoft sind Theorie und Praxis vereint: Nichts klappt und keiner weiß wieso ;)

    Einmal editiert, zuletzt von Das Schwert (9. Dezember 2009 um 09:55)

  • Naja, hast du mal geguckt wie lange der meida player zum starten braucht, und wie lange mein skript startet? :D

    Nochmal zum Post davor:
    Ist jetzt verbessert, da fehlte ne Zeile, was zum totalen crash geführt hat.
    Und in der config.ini stimmte auch was nicht...

    Theorie ist wenn man weiß wie's geht, aber nichts klappt.
    Praxis ist wenn's klappt aber man weiß nicht weiso.

    Bei Microsoft sind Theorie und Praxis vereint: Nichts klappt und keiner weiß wieso ;)

  • Mediaplayer braucht ca. 3 sekunden - so viel Zeit hab ich noch :P

    Darf ich mal anfangen zu meckern? (Nicht bös' gemeint)


    - Verzeichnisse werden nciht rekursiv eingelesen; Wenn ich also D:\Musik wähle, sagt er mir dass keine Dateien gefunden werden. Logisch. Ich hab ja auch ordentlich sortiert.
    - im GUI flackern die Lables für aktuelle Zeit und Totale Zeit. Du solltest sie erst aktualisieren, wenn sich der wert auch wirklich geändert hat.
    - Hotkeys sind fasch schon zu unglückglich gewählt - Wenn man mit einer hand versucht den nächsten Song auszuwählen, bricht man sich ja fast die Finger :D
    - vielleicht solltest du darüber nachdenken auch unterstützung für Media Keys einzubauen. Also die Tasten auf der Tastatur mit denem man direkt auf start / stop / next usw. drücken kann.
    - Keine Lautstärkeanpassung?
    - wenn man Random tooglet, bleibt der Tooltip auf dem Bildschirm

    Also noch ist der WMP mein favorit :P

    Edit: Wie wäre es statt mit Strg+alt+i, die Infos als TrayTip anzuzeigen, sobald man mit der Maus über dem Trayicon ist?

  • Interessantes Script
    interessiert mich wenn du SEuBO's Ratschläge befolgst wird er doch noch mein Favourite.
    Weiter so und nicht aufgeben. ;)

    mfg Ubuntu

  • Neue version
    ==>Nun auch unterstützung für waves (.wav)
    ==>Nun eine zurückspul funktion, die noch nicht läuft (Wenn man auf {MEDIA_PREV} drück (|<<) dann kommt ein neuer song der nach Zufall (???) ausgewählt wird
    ==>Vorspul funktionsbugs: Irgendwann spult er einfach nicht mehr weiter, wenn man dann zurück drückt crasht das programm (Array variable has incorrect number of subscripts or subscript dimension range exceeded)
    ==>Nun über die MEDIA keys! (|<<, >>|, play/pause, und stop eingebaut. Stop beendet (strg alt q geht auchnoch), play pause tut das was der name sagt ;-), genauso wie vorspulen. Nur zurück macht was es will :D
    ==>Random toggle ToolTip bleibt nun nichtmehr auf dem Desktop
    ==>Hotkeys verändert:

    Alt______ | Neu__________________| Funktion
    -----------------|----------------------------------------|-------------------------
    strg+alt+q | strg+alt+q /// MEDIA_STOP| Beenden
    strg+alt+n|____MEDIA_NEXT________| Nächster titel
    strg+alt+r|____strg+alt+s (shuffle)___| Radom playing an/aus
    strg+alt+g|_____strg+alt+a_________| Grafische oberfläche für optionen usw. aufrufen
    gabs nich| ___MEDIA_PREV________| Vorheriger titel
    gabs nich|___MEDIA_PLAY/PAUSE__| Start / Pause für song


    Meine Probleme:
    --> Zum flackern: Ich weiß ich nicht wieso es das tut, er aktuelisert eigentlch nur jede sekunde...
    -->Keine Ahnung wie ich das Zurückspulen hinkrigen soll (Versucht bitte nicht mir zu helfen, könnte zu irreeparablen hirnschäden füren, da das Gehirn überlastet wird. Ich check den code selber nurnoch zu teilen :D

    To do:
    -->Alles unter Meine Probleme lösen
    -->BugFixen
    -->Jemand noch ne Idee? PM schicken oder hier Posten!

    Quelltext:

    Spoiler anzeigen
    [autoit]

    #include <File.au3>
    #include <Sound.au3>
    #include <Array.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <TabConstants.au3>
    #include <WindowsConstants.au3>
    If IniRead (@ScriptDir & "\config.ini", "ops", "path", "error") == "error" Then
    MsgBox (32, "Error!", "No path for mp3 files found in config.ini! Please set one!")
    $newpath = FileSelectFolder ("Path for mp3's", "")
    If @error Then Exit
    IniWrite (@ScriptDir & "\config.ini", "ops", "path", $newpath)
    EndIf
    $isplayed = False
    If $CMDLINE[0] <> 0 Then
    If $CMDLINE[1] == "restart" Then
    $thissong = IniRead (@ScriptDir & "\config.ini", "save", "lastSong", "error")
    IniDelete (@ScriptDir & "\config.ini", "save", "lastSong")
    If $thissong = "error" Then $CMDLINE[1] = ""
    EndIf
    EndIf
    $getsong = False
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;All Features wich you can enable/disable are shown here
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

    HotKeySet ("{MEDIA_NEXT}", "nextSong") ;Press the >>| key for next song for next song
    HotKeySet ("{MEDIA_PREV}", "prevSong")
    HotKeySet ("!^s", "rand") ;Press ctrl+alt+s to disable/enable random playing
    HotKeySet ("{MEDIA_STOP}", "quit") ;Press the stop button to quit
    HotKeySet ("!^q", "quit") ;If you don't have stop, just play/pause (like me) then u can press ctrl+alt+q for quit
    HotKeySet ("!^i", "info") ;Press ctrl+alt+i to get now playing filename
    HotKeySet ("!^a", "gui");Press ctrl+alt+a for GUI (A config etc. window)
    HotKeySet ("{MEDIA_PLAY_PAUSE}", "pausePlay")
    $showTitle = IniRead (@ScriptDir & "\config.ini", "ops", "showSongTitle", True)
    ;If $showTitle = "True" Then $showTitle = True
    ;@If $showTitle = "False" Then $showTitle = False
    ;;;; This program can only play .mp3's! (I think it can play other formats too, but if there e.g is a textfile in the folder the program will crash, if i don't just enable mp3's...
    $rndList = _ArrayCreate ("")
    $rand = IniRead (@ScriptDir & "\config.ini", "ops", "DefaultRandomState", True)
    $path = IniRead (@ScriptDir & "\config.ini", "ops", "path", @ScriptDir)
    If StringInStr ($path, "@ScriptDir") Then
    $splt = StringSplit ($path, "@ScriptDir")
    If $splt[1] == "" Then
    $splt[1] = @ScriptDir ;Replace @ScriptDir to the real scriptpath
    ElseIf $splt[1] <> "" Then
    $x = 0
    Do
    $x += 1
    Until $splt[$x] == ""
    $splt[$x] = @ScriptDir ;Replace @ScriptDir to the real scriptpath
    EndIf
    EndIf
    If StringInStr ($path, "@UserProfileDir") Then
    $splt = StringSplit ($path, "@UserProfileDir")
    If $splt[1] == "" Then
    $splt[1] = @UserProfileDir ;Replace @ScriptDir to the real scriptpath
    ElseIf $splt[1] <> "" Then
    $x = 0
    Do
    $x += 1
    Until $splt[$x] == ""
    $splt[$x] = @UserProfileDir ;Replace @ScriptDir to the real scriptpath
    EndIf
    EndIf

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

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;To here
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    $continue = False
    While 1
    $playedLst = ""
    Global $playedLst[1]
    $lst = check ()
    If Not IsArray ($lst) Then
    MsgBox (32, "Error: not files found!", "No supported files found in " & $path & "! Waiting for files.")
    $exit = False
    While 1
    Sleep (1000)
    $lst = check ()
    If $exit = True Then ExitLoop
    If IsArray ($lst) Then
    $listgui = GUICreate("Generate list", 194, 119, 192, 124)
    $Label1 = GUICtrlCreateLabel('Files found. Please klick "Ok" when', 8, 16, 174, 17)
    $Label2 = GUICtrlCreateLabel("you are ready with moving / copying", 8, 32, 175, 17)
    $Label3 = GUICtrlCreateLabel("new files into the song-folder.", 8, 48, 141, 17)
    $goon = GUICtrlCreateButton("Ok", 56, 80, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    While 1
    $msg = GUIGetMsg ()
    If $msg = -3 Then Exit
    If $msg = $goon Then ExitLoop
    WEnd
    GUIDelete ()
    $exit = True
    EndIf
    WEnd
    MsgBox (0, "Files found", "Found " & $lst[0] & " files. Press ctrl+alt+g AFTER YOU PRESSED OK and switch to 'now playing' to get a list of found songs! Supported file formats are wav and mp3.")
    EndIf
    $i = 1
    Do
    $getsong = IniRead (@ScriptDir & "\config.ini", "saves", "getSong", "False")
    If $rand = True And $lst[0] <> UBound ($rndList) And $getsong = "False" Then
    Do
    $i = Random (1, $lst[0])
    $splt = StringSplit ($i, ".")
    $i = $splt[1]
    Until _ArraySearch ($rndList, $i) == -1
    _ArrayAdd ($rndList, $i)
    $rndList[0] = UBound ($rndList)
    ElseIf $lst[0] == UBound ($rndList) Then
    $rndList = 0
    $rndList = _ArrayCreate ("")
    EndIf
    If $getsong = "False" Then
    IniWrite (@ScriptDir & "\config.ini", "saves", "Song", $lst[$i])
    $open = _SoundOpen ($path & "\" & $lst[$i])
    ElseIf $getsong = "True" Then
    $open = _SoundOpen (IniRead (@ScriptDir & "\config.ini", "saves", "Song", "error"))
    IniDelete (@ScriptDir & "\config.ini", "saves", "getSong")
    EndIf
    If $CMDLINE[0] <> 0 Then
    If $isplayed = False Then
    If $CMDLINE[1] == "restart" Then
    $open = _SoundOpen ($path & "\" & $thissong)
    $isplayed = True
    EndIf
    EndIf
    EndIf
    _ArrayAdd ($playedLst, $i)
    _SoundPlay ($open)
    If $showTitle == True Then
    If $getsong = "False" Then ToolTip ("Now playing " & $lst[$i])
    If $getsong = "True" Then
    ToolTip ("Now playing " & IniRead (@ScriptDir & "\config.ini", "saves", "song", "[Error!]"))
    EndIf
    EndIf
    If $showTitle == True Then $init = TimerInit ()
    $stop = False
    Do
    If $stop = True Then ExitLoop
    Sleep (100)
    If $showTitle == True Then
    If TimerDiff ($init) >= 1500 Then ToolTip ("") ;Show 1,5 seconds the new title
    EndIf
    Until _SoundPos ($open) == _SoundLength ($open)
    $i += 1
    If $stop = False Then _SoundClose ($open)
    Until $i = -1 = $lst[0]
    WEnd
    Func NEXTSONG ()
    _SoundStop ($open)
    _SoundClose ($open)
    $stop = True
    EndFunc
    FUNC PREVSONG ()
    _SoundStop ($open)
    _SoundClose ($open)
    $iniwrite = $lst[UBound ($playedLst)-1]
    $open = _SoundOpen ($path & "\" & $lst[$i])
    IniWrite (@ScriptDir & "\config.ini", "saves", "song", $iniwrite)
    $stop = True
    IniWrite (@ScriptDir & "\config.ini", "saves", "getSong", "True")
    ENDFUNC
    FUNC RAND ()
    If $rand = True Then
    ToolTip ("Random off")
    $rand = False
    ElseIf $rand = False Then
    ToolTip ("Random on")
    $rand = True
    EndIf
    $init = TimerInit ()
    Do
    Sleep (100)
    Until TimerDiff ($init) >= 200 ;Show 0,2 seconds the random state
    ENDFUNC
    FUNC QUIT ()
    Exit
    ENDFUNC
    FUNC INFO ()
    ToolTip (IniRead (@ScriptDir & "\config.ini", "saves", "Song", "error"))
    $init = TimerInit ()
    Do
    Sleep (100)
    Until TimerDiff ($init) >= 1500 ; Show 1,5 seconds the title
    ToolTip ("")
    ENDFUNC
    FUNC GUI ()
    ToolTip ("")
    #Region ### START Koda GUI section ### Form=C:\Users\----\Desktop\Music\Form1.kxf
    $Form1 = GUICreate("Backround muzik GUI", 625, 443, 192, 124)
    $tab = GUICtrlCreateTab(0, 0, 617, 441)
    GUICtrlSetFont(-1, 8, 400, 0, "Courier New")
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Now playing")
    $Label7 = GUICtrlCreateLabel("Song", 72, 32, 29, 17)
    $songlist = GUICtrlCreateList("", 72, 56, 201, 370)
    $Label8 = GUICtrlCreateLabel("Now playing", 224, 32, 62, 17)
    $PlayMarkedSong = GUICtrlCreateButton("Play marked song", 288, 400, 115, 25, $WS_GROUP)
    $timeplayed = GUICtrlCreateLabel("Time played:", 288, 344, 136, 17)
    $timeleft = GUICtrlCreateLabel("Song length:", 432, 344, 119, 17)
    $TabSheet2 = GUICtrlCreateTabItem("Ini Configuration")
    $auostartBackMuz = GUICtrlCreateCheckbox("Put Backround muzik into startup (Autorun Backround muzik on windows start)", 56, 120, 521, 17)
    $autornd = GUICtrlCreateCheckbox("Autostart random playing", 56, 56, 521, 17)
    If IniRead (@ScriptDir & "\config.ini", "ops", "DefaultRandomPlaying", True) == True Then GUICtrlSetState ($autornd, $GUI_CHECKED)
    $regstart = GUICtrlCreateRadio("Autostart over reg-entry", 88, 160, 481, 17)
    $folderstart = GUICtrlCreateRadio("Autostart over startupfolder", 88, 184, 505, 17)
    If RegRead ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik") Or RegRead ("HKLM\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik") Then
    GUICtrlSetState ($regstart, $GUI_CHECKED)
    GUICtrlSetState ($auostartBackMuz, $GUI_CHECKED)
    ElseIf FileExists (@StartupCommonDir & "\Background Muzik.lnk") Or FileExists (@StartupDir & "\Background Muzik.lnk") Then
    GUICtrlSetState ($folderstart, $GUI_CHECKED)
    GUICtrlSetState ($auostartBackMuz, $GUI_CHECKED)
    Else
    GUICtrlSetState ($regstart, $GUI_CHECKED)
    EndIf
    $everyone = GUICtrlCreateCheckbox("For everyone who uses this computer", 88, 208, 505, 17)
    $save = GUICtrlCreateButton("Save changes", 56, 360, 91, 25, $WS_GROUP)
    $restart = GUICtrlCreateButton("Restart program (Required for new mp3 path)", 152, 360, 267, 25, $WS_GROUP)
    $showTitelfield = GUICtrlCreateCheckbox("Show new songtitel if next song starts", 56, 264, 521, 17)
    If IniRead (@ScriptDir & "\config.ini", "ops", "showSongTitle", True) == True Then GUICtrlSetState ($showTitelfield, $GUI_CHECKED)
    $Label11 = GUICtrlCreateLabel("Folder with mp3's:", 8, 304, 88, 17)
    $folderpath = GUICtrlCreateInput("", 104, 304, 441, 21)
    GUICtrlSetData ($folderpath, IniRead (@ScriptDir & "\config.ini", "ops", "path", @ScriptDir))
    $changeFolder = GUICtrlCreateButton("Change", 544, 304, 67, 25, $WS_GROUP)
    $TabSheet3 = GUICtrlCreateTabItem("About")
    GUICtrlSetState(-1,$GUI_SHOW)
    $Label1 = GUICtrlCreateLabel("Backround muzik by Das Schwert (The Sword)", 32, 64, 225, 17)
    $Label2 = GUICtrlCreateLabel("For support etc send a mail to [email='schwertsoft@web.de'][/email].", 32, 80, 249, 17)
    $Label3 = GUICtrlCreateLabel("Homepage:", 32, 96, 59, 17)
    $HPLnk = GUICtrlCreateLabel("http://schwertsoft.ucoz.com", 96, 96, 138, 17)
    GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
    GUICtrlSetColor(-1, 0x0000FF)
    GUICtrlSetCursor (-1, 0)
    $Label5 = GUICtrlCreateLabel("(This page is german!)", 240, 96, 108, 17)
    $Label6 = GUICtrlCreateLabel("If you have any idea to make my progs better, then send it to me!", 32, 128, 309, 17)
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $c = 1
    $string = ""
    Do
    If $lst[$c] <> $lst[$i] And $lst[$c] <> IniRead (@ScriptDir & "\config.ini", "saves", "Song", "error") Then
    $string &= $lst[$c] & "|"
    ElseIf $lst[$c] == IniRead (@ScriptDir & "\config.ini", "saves", "Song", "error") Then
    $string &= IniRead (@ScriptDir & "\config.ini", "saves", "Song", "error") & "------Playing...|"
    Endif
    $c += 1
    Until $c = $lst[0]
    $string &= $lst[$c]
    GUICtrlSetData ($songlist, $string)
    $init2 = TimerInit ()
    $last = 0
    While 1
    If TimerDiff ($init2) + 1000 >= $last Then
    $last = TimerDiff ($init2)
    $played = _SoundPos ($open)
    GUICtrlSetData ($timeplayed, $played)
    GUICtrlSetData ($timeleft, _SoundLength ($open))
    EndIf
    $msg = GUIGetMsg ()
    If $msg = -3 And (MsgBox (36, "Warning!", "If you close the window before klicking 'Save changes' all changes will be lost!") == 6) Then
    GUIDelete ()
    Return 0
    EndIf
    If $msg = $PlayMarkedSong Then
    $song = GUICtrlRead ($songlist)
    $i = 1
    Do
    If $lst[$i] == $song Then
    ExitLoop
    EndIf
    $i += 1
    Until $lst[0] = $i -1
    _SoundStop ($open)
    _SoundClose ($open)
    ;$i -= 1
    $iniwrite = $lst[$i]
    $open = _SoundOpen ($path & "\" & $lst[$i])
    IniWrite (@ScriptDir & "\config.ini", "saves", "song", $iniwrite)
    $stop = True
    IniWrite (@ScriptDir & "\config.ini", "saves", "getSong", "True")
    GUIDelete ()
    Return 0
    EndIf
    If $msg = $save Then
    RegDelete ("HKLM\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik")
    RegDelete ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik")
    FileDelete (@StartupCommonDir & "\Background Muzik.lnk")
    FileDelete (@StartupDir & "\Background Muzik.lnk")
    If GUICtrlRead ($showTitelfield) == $GUI_CHECKED Then
    IniWrite (@ScriptDir & "\config.ini", "ops", "showSongTitle", True)
    ElseIf GUICtrlRead ($showTitelfield) == $GUI_UNCHECKED Then
    IniWrite (@ScriptDir & "\config.ini", "ops", "showSongTitle", False)
    EndIf
    If GUICtrlRead ($autornd) == $GUI_CHECKED Then
    IniWrite (@ScriptDir & "\config.ini", "ops", "DefaultRandomPlaying", True)
    Else
    IniWrite (@ScriptDir & "\config.ini", "ops", "DefaultRandomPlaying", False)
    EndIf
    IniWrite (@ScriptDir & "\config.ini", "ops", "path", GUICtrlRead ($folderpath))
    If GUICtrlRead ($auostartBackMuz) == $GUI_CHECKED Then
    If GUICtrlRead ($everyone) == $GUI_CHECKED Then
    $users = "everyone"
    ElseIf GUICtrlRead ($everyone) == $GUI_UNCHECKED Then
    $user = "me"
    EndIf
    If GUICtrlRead ($regstart) == $GUI_CHECKED Then
    $startmethode = "reg"
    ElseIf GUICtrlRead ($folderstart) == $GUI_CHECKED Then
    $startmethode = "folder"
    EndIf
    If $startmethode = "reg" Then
    If $user == "me" Then
    RegWrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik", "REG_SZ", @ScriptFullPath)
    ElseIf $user == "everyone" Then
    RegWrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Background Muzik", "REG_SZ", @ScriptFullPath)
    EndIf
    ElseIf $startmethode = "folder" Then
    If $user = "everyone" Then
    FileCreateShortcut (@ScriptFullPath, @StartupCommonDir & "\Background Muzik.lnk")
    ElseIf $user = "me" Then
    FileCreateShortcut (@ScriptFullPath, @StartupDir & "\Background Muzik.lnk")
    Else
    MsgBox (32, "Fatal error!", "Fatal error!")
    EndIf
    EndIf
    EndIf
    EndIf
    If $msg = $restart Then
    IniWrite (@ScriptDir & "\config.ini", "saves", "lastSong", $lst[$i])
    ShellExecute (@ScriptFullPath, "restart")
    Exit
    EndIf
    If $msg = $HPLnk Then
    $splt = StringSplit (RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", ""), '"')
    $browser = $splt[2]
    ShellExecute ($browser, "http://schwertsoft.ucoz.com")
    EndIf
    WEnd
    ENDFUNC
    FUNC ONAUTOITEXIT ()
    IniDelete (@ScriptDir & "\config.ini", "saves", "song")
    IniDelete (@ScriptDir & "\config.ini", "saves", "getSong")
    ENDFUNC ;Made by Das Schwert

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

    FUNC CHECK ()
    $lst = _FileListToArray ($path, "*.wav")
    $lst2 = _FileListToArray ($path, "*.mp3")
    If IsArray ($lst) And IsArray ($lst2) Then
    $v = 1
    Do
    _ArrayAdd ($lst, $lst2[$v])
    $v += 1
    Until $v -1 = $lst[0]
    $lst[0] = UBound ($lst)
    ElseIf IsArray ($lst2) Then
    $lst = 0
    $lst = _FileListToArray ($path, "*.mp3")
    ElseIf IsArray ($lst) Then
    $lst2 = 0;Just to stay clean and don't fill the memory with useless stuff
    EndIf
    Return $lst
    ENDFUNC
    FUNC PAUSEPLAY ()
    If _SoundStatus ($open) == "playing" Then
    _SoundPause ($open)
    ElseIf _SoundStatus ($open) == "paused" Then
    _SoundPlay ($open)

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

    Else
    MsgBox (0, "Failure", "Can't start/stop sound when sound status is " & _SoundStatus ($open) & ".")
    EndIf
    EndFunc

    [/autoit]

    Zur ini file: Keine Ini mehr benötigt.
    Alle optionen lassen sich über strg+alt+g lösen!!! :thumbup:

    Theorie ist wenn man weiß wie's geht, aber nichts klappt.
    Praxis ist wenn's klappt aber man weiß nicht weiso.

    Bei Microsoft sind Theorie und Praxis vereint: Nichts klappt und keiner weiß wieso ;)

    4 Mal editiert, zuletzt von Das Schwert (3. Januar 2010 um 17:02)

  • Ja, hatte ich vergessen rein zu schreiben. Hab ich jetzt nachgetragen... Danke :)

    Theorie ist wenn man weiß wie's geht, aber nichts klappt.
    Praxis ist wenn's klappt aber man weiß nicht weiso.

    Bei Microsoft sind Theorie und Praxis vereint: Nichts klappt und keiner weiß wieso ;)

  • Hallo.
    Also ich finde das is ne tolle Idee,
    aber der Windows Media Player is viel besser.
    Da hab ich meine Playlist, und in der Taskbar kann ich auf Pause klicken oder mir sogar
    ne Visualisierung anschauen.
    Außerdem gibst du dem User die möglichkeit den Player in den Autostart zu stecken,
    das find ich net gut, denn wenn ich meinen PC hochfahre möchte ich nicht direkt Musik hören.
    MfG. PrideRage

    Meine Projekte:
    ClipBoard Manager (beendet)
    Gutes ClipBoard Verwaltungs Programm mit nützlichen Funktionen.

    HTML Creator (beendet)
    Nützliches Tool um schnell ein eigenes HTML Dokument zu erstellen.