Mir ist gerade langweilig, deshalb habe ich sogar einen kleinen Audioplayer gescriptet.
Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
Global $txt_NoTitel = "???"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Audioplayer", 163, 78, 192, 114)
$Progress1 = GUICtrlCreateProgress(5, 5, 150, 16)
$btn_OpenFile = GUICtrlCreateButton("open", 5, 25, 60, 25)
$btn_HandleFile = GUICtrlCreateButton("play/ break", 95, 25, 60, 25)
$lbl_Title = GUICtrlCreateLabel ($txt_NoTitel, 5, 58, 50, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $hFile, $length, $FileName, $io = 0
While Sleep (10)
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $btn_OpenFile
Local $path = FileOpenDialog ("Select mp3", @ScriptDir, "Audio (*.mp3; *.wav;)", 1+4)
if @error Then
GUICtrlSetData ($lbl_Title, $txt_NoTitel)
Else
$hFile = _SoundOpen ($path)
if not @error Then
Local $sSplit = StringSplit ($path, "\")
if IsArray ($sSplit) Then
Local $sSize = UBound ($sSplit) -1
if $sSize > 0 Then
GUICtrlSetData ($lbl_Title, $sSplit[$sSize])
EndIf
EndIf
Else
$hFile = 0
MsgBox (46,"Error","Cannot open file!")
GUICtrlSetData ($lbl_Title, $txt_NoTitel)
EndIf
EndIf
Case $btn_HandleFile
if $hFile <> "" Then
if $io = 0 Then
_LPlaySound($hFile)
$io = 1
Else
_LPauseSound()
$io = 0
EndIf
Else
MsgBox (64,"Info","You have to select a file!")
EndIf
EndSwitch
if $hFile <> 0 or $hFile <> "" Then
Local $hLenght = _SoundLength ($hFile, 2)
Local $hPosition = _SoundPos ($hFile, 2)
if not @error Then
Local $SoundLenght = $hLenght / 1000
Local $SoundPosition = $hPosition / 1000
Local $secDiff = $SoundLenght / $SoundPosition
Local $procDiff = 100 / $secDiff
GUICtrlSetData ($Progress1, $procDiff)
EndIf
EndIf
WEnd
Func _LPlaySound($file)
_SoundPlay ($file, 0)
EndFunc
Func _LPauseSound()
_SoundPause($hFile)
EndFunc
Wollte eigentlich die Progressbar zu Ende scripten, aber leider muss ich meine Termine einhalten. Werde es später editieren ;)
€: Paar kleine Textänderungen. Zudem funktioniert nun die Progressbar und habe einen Label hinzugefügt, der den Soundtitel anzeigt!