Ich hab folgendes problem ich hab in mein script mit der led laufschrift ergänzt und seitdem stürtzt autoit ab.
währe toll wenn mir jmd helfen könnte
Spoiler anzeigen
#include <GDIPlus.au3>
#include <Bass.au3>
#include <_GetFilesFolder_Rekursiv.au3>
#include <GuiListView.au3>
#include <Misc.au3>
#include <BassConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <GUIConstantsEx.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <GDIPlusConstants.au3>
#include <basstags.au3>
#NoTrayIcon
;===================================================================================================
; INRadio-Localtuner by JuraX
;===================================================================================================
Global Const $WM_DROPFILESplay = 0x0233
Global Const $WM_DROPFILES = 0x0233
Global $hwnd
Global $iX2 = 0, $iW, $iStep = 2
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Global $hBitmapBuffer = _GDIPlus_BitmapCreateFromGraphics(800, 200, $hGraphics)
Global $hGraphicsBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmapBuffer)
_GDIPlus_GraphicsClear($hGraphicsBuffer, 0xFF000000)
Global $hBitmapLed = _CreateLedBitmap($hGraphics, "INR", 200, 50, $iStep, $iStep, 0xFFFFBB00, 0x66111122)
$iW = @extended
Global $gaDropFiles[1]
Global $aItem[2]
Global $playing_state = -1
Global $MusicHandle
Global $titelnummer = 0
Global $progress_slider, $slots, $hwnd
Global $fftstruct = DllStructCreate("float[128]")
Global $song_length = _BASS_ChannelGetLength($MusicHandle, $BASS_POS_BYTE)
Global $tags
Global $ARRPLAY
#Region StartUp
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]#Region OPT
Opt("TrayMenuMode", 1)
Opt("MouseCoordMode", 0)
#EndRegion OPT
#Region Tray
$uottray = TrayCreateItem("Anzeigen")
$totray = TrayCreateItem("Verstecken")
$deleate = TrayCreateItem("Schließen")
TraySetState()
#EndRegion Tray
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Field=INR|Jurax-Multimedia
#AutoIt3Wrapper_Res_Field=ProductVersion|1.3
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;Bass StartUp
_BASS_STARTUP(@ScriptDir & "\BASS.dll")
_Bass_Tags_Startup("BassTags.dll")
_BASS_Init(0, -1, 44100, 0, "")
If @error Then
MsgBox(0, "Error", "Sound konnte nicht Initialisiert werden!")
Exit
EndIf
#Region Register
If IsDeclared("Musichandle") Then
AdlibRegister("tagout", 5000)
EndIf
AdlibRegister("Aktualisieren")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES_FUNC')
GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
#EndRegion Register
[/autoit] [autoit][/autoit] [autoit]#EndRegion StartUp
[/autoit] [autoit][/autoit] [autoit]#Region GUI
$Width = 380
$Height = 650
$hwnd = GUICreate("INRadio-Localtuner", $Width, $Height, -1, -1, Default, $WS_EX_ACCEPTFILES)
$TITART = GUICtrlCreateLabel("", 130, 220, 500, 70)
$slots = GUICtrlCreateLabel(GUICtrlRead($progress_slider), 8, 8, 150, 17)
$Close = GUICtrlCreateButton("Close", 296, 160, 75, 25, 0)
;$Play = GUICtrlCreateButton("Play", 216, 160, 75, 25, 0)
$Stop = GUICtrlCreateButton("Stop", 136, 160, 75, 25, 0)
$newfile = GUICtrlCreateButton("Andere Datei", 36, 160, 75, 25, 0)
$progress_slider = GUICtrlCreateProgress(8, 32, 236, 20)
$ordner = GUICtrlCreateButton("Neue Bibliothek", 136, 330)
GUICtrlCreateLabel("Lautstärke", 8, 190, 80, 20)
$Volume_slider = GUICtrlCreateSlider(8, 250, 366, 80)
$hListView = GUICtrlCreateListView('Dateiname|Pfad', 10, 375, 350, 200)
GUICtrlSetLimit($progress_slider, 100)
GUICtrlSetData($Volume_slider, 100)
SoundSetWaveVolume(100)
$Playliste = GUICtrlCreateButton("Playliste abspielen", 20, 330)
#Region BIB Füllen
$return = IniRead(@ScriptDir & "\INRadio.ini", "Load", "BIB", "")
If $return = "" Then
$return = 'C:\Users\' & @UserName & '\Desktop'
Endif
$returnputin = _GetFilesFolder_Rekursiv($return, "mp3", 0)
For $i = 1 To $returnputin[0]
$dateiname = StringSplit($returnputin[$i], "\")
GUICtrlCreateListViewItem($dateiname[$dateiname[0]] & "|" & $returnputin[$i], $hListView)
Next
#EndRegion BIB Füllen
$rightVol = GUICtrlCreateProgress(8, 88, 236, 17)
GUICtrlSetLimit(-1, 100, 0)
GUICtrlCreateLabel("Right Channel Volume Level", 8, 112, 150, 17)
$LeftVol = GUICtrlCreateProgress(8, 136, 236, 17)
GUICtrlSetLimit(-1, 100, 0)
GUICtrlCreateLabel("Left Channel Volume Level", 8, 64, 150, 17)
GUISetState()
#EndRegion GUI
#Region GDIstartup
_GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE)
_GDIPlus_Startup()
$iX = 120
$iY = 145
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($iX, $iY, $graphics)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
_GDIPlus_GraphicsClear($backbuffer)
$pen1_size = 4
$pen1 = _GDIPlus_PenCreate(0, $pen1_size)
$pen2_size = 4
$pen2 = _GDIPlus_PenCreate(0, $pen2_size)
$pen3_size = 3
$pen3 = _GDIPlus_PenCreate(0, $pen3_size)
$fall_speed_l_threshold = 0
$fall_speed_r_threshold = 0
$equalizer_width = 24
$max_l = 0
$max_r = 0
$fall_speed = 5
$fire_up = 15
$fft_start = 7
$fft_end = 127
$fft_boost = 750
$dy = Int($iY / ($fft_end - $fft_start)) + $pen3_size
$dyy = Int($iY / $dy / 2)
$eq = 1
Dim $mpos[2]
#EndRegion GDIstartup
#Region Loop
[/autoit] [autoit][/autoit] [autoit]While(True)
Sleep(200)
$iX2 -= $iStep
If $iX2 + $iW < 0 Then $iX2 += $iW
_GDIPlus_GraphicsDrawImage($hGraphicsBuffer, $hBitmapLed, $iX2, 0)
_GDIPlus_GraphicsDrawImage($hGraphicsBuffer, $hBitmapLed, $iX2 + $iW, 0)
_WinAPI_RedrawWindow($hwnd, 0, 0, $RDW_INTERNALPAINT)
_GUICtrlListView_SetColumnWidth($hListView, 1, 0)
$soundoff = _SoundGetWaveVolume()
GUICtrlSetData($Volume_slider, $soundoff)
If $playing_state = 1 Then
$song_length = _BASS_ChannelGetLength($MusicHandle, $BASS_POS_BYTE)
$current = _BASS_ChannelGetPosition($MusicHandle, $BASS_POS_BYTE)
$percent = Round(($current / $song_length) * 100, 0)
ConsoleWrite("MH: " & $MusicHandle & " Current: " & $current & " song_length: " & $song_length & @CRLF)
GUICtrlSetData($progress_slider, $percent)
$levels = _BASS_ChannelGetLevel($MusicHandle)
$rightChLvl = _LoWord($levels)
$rightChLvlper = Round(($rightChLvl / 32768) * 100, 0)
$LeftChLvl = _HiWord($levels)
$leftChLvlper = Round(($LeftChLvl / 32768) * 100, 0)
If IsArray($ARRPLAY) Then
If $current = $song_length Then
GUICtrlSetData($progress_slider, 0)
If $playing_state = 1 Then
_BASS_ChannelStop($MusicHandle)
EndIf
$titelnummer += 1
If $titelnummer = UBound($ARRPLAY) - 1 Then $titelnummer = 0
; Sleep (50)
$playing_state = 1
$MusicHandle = _BASS_StreamCreateFile(False, $ARRPLAY[$titelnummer][1], 0, 0, 0)
_BASS_ChannelPlay($MusicHandle, 0)
EndIf
EndIf
Else
$rightChLvlper = 0
$leftChLvlper = 0
EndIf
GUICtrlSetData($rightVol, $rightChLvlper)
GUICtrlSetData($LeftVol, $leftChLvlper)
Display_Vis($eq)
$Msg = GUIGetMsg()
$tmsg = TrayGetMsg()
Switch $tmsg
Case $uottray
GUISetState(@SW_SHOW)
Case $totray
GUISetState(@SW_HIDE)
Case $deleate
EXITF()
EndSwitch
Switch $Msg
Case $Close, $GUI_EVENT_CLOSE
EXITF()
; Case $Play
Case $Stop
If $playing_state = 1 Then
_BASS_ChannelStop($MusicHandle)
$playing_state = -1
EndIf
$ARRPLAY = 0
Sleep(50)
Case $newfile
If $playing_state = 1 Then
_BASS_ChannelStop($MusicHandle)
EndIf
$ARRPLAY = 0
Sleep(50)
$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")
$MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
_BASS_ChannelPlay($MusicHandle, 0)
$playing_state = 1
Case $Volume_slider
SoundSetWaveVolume(GUICtrlRead($Volume_slider))
Case $ordner
$var = FileSelectFolder("Ordner wählen", "")
IniWrite(@ScriptDir & "\INRadio.ini", "Load", "BIB", $var)
Case $Playliste
$ARRPLAY = _ListViewToArray($hListView)
$playing_state = 1
$MusicHandle = _BASS_StreamCreateFile(False, $ARRPLAY[$titelnummer][1], 0, 0, 0)
_BASS_ChannelPlay($MusicHandle, 0)
Case $GUI_EVENT_DROPPED
For $i = 0 To UBound($gaDropFiles) - 1
GUICtrlCreateListViewItem(StringRegExpReplace($gaDropFiles[$i], '.*\\(.*)\..*', '$1'), $hListView)
_GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE)
Next
EndSwitch
[/autoit] [autoit][/autoit] [autoit]WEnd
[/autoit] [autoit][/autoit] [autoit]#EndRegion Loop
$mpos = MouseGetPos()
If $mpos[0] >= $Width - $iX - 10 And $mpos[0] <= $Width - 10 And $mpos[1] > 8 And $mpos[1] <= $iY + 8 And _IsPressed("01", "user32.dll") And WinActive($hwnd) Then
$eq *= -1
EndIf
#Region Func's
Func WM_DROPFILES_FUNC($hwnd, $msgID, $wParam, $lParam) ; diese Funktion wird benötigt, damit man auch mehrere Dateien droppen kann
Local $nSize, $pFileName
Local $nAmt = DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', 0xFFFFFFFF, 'ptr', 0, 'int', 255)
For $i = 0 To $nAmt[0]
$nSize = DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', $i, 'ptr', 0, 'int', 0)
$nSize = $nSize[0] + 1
$pFileName = DllStructCreate('wchar[' & $nSize & ']')
DllCall('shell32.dll', 'int', 'DragQueryFileW', 'hwnd', $wParam, 'int', $i, 'ptr', DllStructGetPtr($pFileName), 'int', $nSize)
$filename = DllStructGetData($pFileName, 1) ;Dateinamen holen
ConsoleWrite($filename & @CRLF)
ReDim $gaDropFiles[$i + 1]
$gaDropFiles[$i] = DllStructGetData($pFileName, 1)
$pFileName = 0
Next
;_ArrayDisplay($gaDropFiles)
For $i = 0 To UBound($gaDropFiles) - 2 ;kommt derzeit immer noch ein leerer Eintrag am schluss
GUICtrlCreateListViewItem(StringRegExpReplace($gaDropFiles[$i], '.*\\(.*)\..*', '$1') & "|" & $gaDropFiles[$i], $hListView)
Next
_GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE) ;erst wenn alle eigefügt sind
EndFunc ;==>WM_DROPFILES_FUNC
Func Aktualisieren()
$Sliderstatus = GUICtrlRead($progress_slider)
GUICtrlSetData($slots, $Sliderstatus)
EndFunc ;==>Aktualisieren
Func WM_NOTIFY($hwnd, $msgID, $wParam, $lParam);Für Doppelcklick Erkennung
Local $tagNMHDR, $event, $hwndFrom, $code
$tagNMHDR = DllStructCreate("int;int;int", $lParam)
If @error Then Return 0
$code = DllStructGetData($tagNMHDR, 3)
If $wParam = $hListView And $code = -3 And _GUICtrlListView_GetSelectedCount($hListView) > 0 Then
For $i = 0 To _GUICtrlListView_GetItemCount($hListView)
IF _GUICtrlListView_GetItemSelected($hListView, $i) Then
$aItem = _GUICtrlListView_GetItemTextArray($hListView, $i)
;~ In aItem[1] steht der Dateiname und in $aItem[2] der Pfad zincl. Dateinamen
_LeftDblClick()
EndIf
Next
Endif
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _LeftDblClick()
If $playing_state = 1 Then
_BASS_ChannelStop($MusicHandle)
EndIf
$titelnummer = -1
$file = $aItem[2]
$MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
_BASS_ChannelPlay($MusicHandle, 0)
$playing_state = 1
EndFunc ;==>_LeftDblClick
Func Display_Vis($eq = 1)
_GDIPlus_GraphicsClear($backbuffer, 0x80F0F0F0)
If $eq > 0 Then
$levels = _BASS_ChannelGetLevel($MusicHandle)
$LeftChLvl = $leftChLvlper ;Round(_HiWord($levels) / $iY, 0)
$rightChLvl = $rightChLvlper ;Round(_LoWord($levels) / $iY, 0)
If $max_l <= $LeftChLvl Then ;fire up higest line
$max_l = $LeftChLvl + $fire_up
$fall_speed_l_threshold = 20
Else
If $fall_speed_l_threshold <= 0 Then ;increase fall speed of highest line faster until threshold is <= 0 (second fall part)
If $max_l > $LeftChLvl + $pen2_size * 2 Then $max_l -= $fall_speed
Else
$fall_speed_l_threshold -= 1 ;increase fall speed of highest line by slower until threshold is <= 0 (first fall part)
If $max_l > $LeftChLvl + $pen2_size * 2 Then $max_l -= $fall_speed / 3
EndIf
EndIf
If $max_r <= $rightChLvl Then
$max_r = $rightChLvl + $fire_up
$fall_speed_r_threshold = 20
Else
If $fall_speed_r_threshold <= 0 Then
If $max_r > $rightChLvl + $pen2_size * 2 Then $max_r -= $fall_speed
Else
$fall_speed_r_threshold -= 1
If $max_r > $rightChLvl + $pen2_size * 2 Then $max_r -= $fall_speed / 3
EndIf
EndIf
_BASS_ChannelGetData($MusicHandle, DllStructGetPtr($fftstruct), $BASS_DATA_FFT256)
For $i = $fft_start To $fft_end Step $dy
$fft = Round(DllStructGetData($fftstruct, 1, $i + 1) * $fft_boost)
$r = (-(Cos(1.7 * $fft / 256) + 1) * 0.5) * 256
$g = ((Cos(4 * $fft / 256) + 1) * 0.5) * 256
$b = 0
_GDIPlus_PenSetColor($pen3, "0xFF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))
_GDIPlus_GraphicsDrawLine($backbuffer, $iX / 5, $i + $dyy, $iX / 5 + $fft, $i + $dyy, $pen3)
Next
EndIf
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, $Width - $iX - 10, 8, $iX, $iY)
EndFunc ;==>Display_Vis
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
$p = ""
Return $WaveVol
EndFunc ;==>_SoundGetWaveVolume
Func EXITF()
_BASS_Stop()
_BASS_Free()
_GDIPlus_BitmapDispose($hBitmapLed)
_GDIPlus_GraphicsDispose($hGraphicsBuffer)
_GDIPlus_BitmapDispose($hBitmapBuffer)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_PenDispose($pen1)
_GDIPlus_PenDispose($pen2)
_GDIPlus_PenDispose($pen3)
_GDIPlus_BitmapDispose($bitmap)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_GraphicsDispose($backbuffer)
_GDIPlus_Shutdown()
$fftstruct = 0
ProcessClose("Radiotuner.exe")
AdlibUnRegister("Aktualisieren")
Exit
EndFunc ;==>EXITF
Func _ListViewToArray($hListView)
If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView)
Local $sString = ""
For $i = 0 To _GUICtrlListView_GetItemCount($hListView) - 1
$sString &= _GUICtrlListView_GetItemTextString($hListView, $i)
$sString &= ";"
Next
$aSplit = StringSplit(StringTrimRight($sString, 1), ";", 2)
$iUB1 = UBound($aSplit)
Dim $aRet[$iUB1][1]
For $i = 0 To $iUB1 - 1
$aSplit2 = StringSplit($aSplit[$i], "|", 2)
$iUB2 = UBound($aSplit2)
If $iUB2 > UBound($aRet, 2) Then ReDim $aRet[$iUB1][$iUB2]
For $j = 0 To $iUB2 - 1
$aRet[$i][$j] = $aSplit2[$j]
Next
Next
Return $aRet
EndFunc ;==>_ListViewToArray
Func TAGOUT()
$tags = _Bass_Tags_Read($MusicHandle, "%TITL" & "-" & "%ARTI")
GUICtrlSetData($TITART, $tags)
EndFunc ;==>TAGOUT
Func _WM_PAINT($hwnd, $Msg, $wParam, $lParam)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmapBuffer, 0, 0)
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_PAINT
Func _CreateLedBitmap($hGraphics, $sText, $iW, $iH, $iLedOffSet, $iLedSize, $iOnColor = 0xFFFFBB00, $iOffColor = 0x88111122, $sFont = "Arial")
$sText = StringUpper(StringReplace($sText, @LF, ""))
Local $hBrush = _GDIPlus_BrushCreateSolid($iOnColor)
Local $hBrushOff = _GDIPlus_BrushCreateSolid($iOffColor)
Local $hFormat = _GDIPlus_StringFormatCreate()
Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local $hFont = _GDIPlus_FontCreate($hFamily, $iH, 1, 2)
Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sText, $hFont, $tLayout, $hFormat)
Local $iWidth = Ceiling(DllStructGetData($aInfo, "Width")) + $iW
$iWidth -= Mod($iWidth, $iLedOffSet)
Local $iHeight = Ceiling(DllStructGetData($aInfo, "Height"))
DllStructSetData($aInfo, "Y", -Round(($iHeight - $iH) / 3))
Local $hBitmapTxt = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Local $hBitmapLed = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Local $hGraphicsTxt = _GDIPlus_ImageGetGraphicsContext($hBitmapTxt)
Local $hGraphicsLed = _GDIPlus_ImageGetGraphicsContext($hBitmapLed)
_GDIPlus_GraphicsClear($hGraphicsTxt, $iOffColor)
_GDIPlus_GraphicsDrawStringEx($hGraphicsTxt, $sText, $hFont, $aInfo, $hFormat, $hBrush)
Local $BitmapData = _GDIPlus_BitmapLockBits($hBitmapTxt, 0, 0, $iWidth, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
Local $Stride = DllStructGetData($BitmapData, "Stride")
Local $Width = DllStructGetData($BitmapData, "Width")
Local $Height = DllStructGetData($BitmapData, "Height")
Local $Scan0 = DllStructGetData($BitmapData, "Scan0")
Local $PixelData, $Color = Hex($iOnColor)
For $row = 0 To $Height - 1 Step $iLedOffSet
For $col = 0 To $Width - 1 Step $iLedOffSet
$PixelData = DllStructCreate("dword", $Scan0 + ($row * $Stride) + ($col * 4))
If Hex(DllStructGetData($PixelData, 1)) = $Color Then
_GDIPlus_GraphicsFillEllipse($hGraphicsLed, $col, $row, $iLedSize, $iLedSize, $hBrush)
Else
_GDIPlus_GraphicsFillEllipse($hGraphicsLed, $col, $row, $iLedSize, $iLedSize, $hBrushOff)
EndIf
Next
Next
_GDIPlus_BitmapUnlockBits($hBitmapTxt, $BitmapData)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_BrushDispose($hBrushOff)
_GDIPlus_BitmapDispose($hBitmapTxt)
_GDIPlus_GraphicsDispose($hGraphicsTxt)
_GDIPlus_GraphicsDispose($hGraphicsLed)
Return SetExtended($iWidth, $hBitmapLed)
EndFunc ;==>_CreateLedBitmap
#EndRegion Func's
[/autoit]