#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=FS-Tool.ico
#AutoIt3Wrapper_outfile=FS-Tool.exe
#AutoIt3Wrapper_Run_Obfuscator=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Region ### Includes ###
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include <GIFAnimation.au3>
#include <GDIPlus.au3>
#EndRegion ### End Includes ###
#EndRegion ### End Includes ###


HotKeySet("{esc}","_Abbrechen")


#Region ### Declaration ###
Global $iWidht = 825
Global $iHeight = 610
Global $iLeft = (@DesktopWidth-$iWidht) / 2
Global $iTop = (@DesktopHeight-$iHeight) / 2
Global $HH = 0
Global $MM = 0
Global $SS = 0
Global $Init = 0
Global $Diff = 0
Global $Abbruchcode = 0
Global $Volumen = 0
Global $VolumenEinzel = 0
Global $AnzahlFiles = 0
Global $AnzahlEinzel = 0
Global $Fortschritt = 0
Global $AnzVideos = 0
Global $AnzMusik = 0
Global $AnzBilder = 0
Global $AnzSonstige = 0
Global $Text = ""
Global $sText = ""
Global $VideoFormate = ".+\.avi;.+\.flv;.+\.mp4;.+\.mkv"
Global $MusikFormate = ".+\.mp3;.+\.m4a;.+\.aac;.+\.wav;.+\.wma"
Global $BildFormate = ".+\.jpg;.+\.bmp;.+\.png"
Global $ColorSwitch = 0
Global $SizeVideos = 0
Global $SizeMusik = 0
Global $SizeBilder = 0
Global $SizeSonstige = 0
Global $BerichtMarkieren = 0
Global $BerichtSuche = 0
Global $Index = 0
Global $Uebereinstimmungen = 0
Global $ItemSelect = 0
Global $klText = ""
Global $oShellApp = ObjCreate('shell.application')
Global $sTempFolder = @TempDir & "\GIFS"
DirCreate($sTempFolder)
Global $sFile = @ScriptDir & "\Bilder FS-Tool\Loading.gif"
Global $sAppDir = @AppDataDir & '\FST'
If Not FileExists($sAppDir) Then DirCreate($sAppDir)
Global $sIniPath = $sAppDir & '\FST.ini'
Global $sSearchPath = IniRead($sIniPath, 'Prefs', 'SearchPath', @MyDocumentsDir & '\')
#EndRegion ### Declaration ###
#EndRegion ### Declaration ###


#Region ### START Koda GUI section FSTool###
$hFSTool = GUICreate("O2Candoo - FS-Tool [Version 26.9.0019] - Copyright © 2012 CosmosBase Corporation. Alle Rechte vorbehalten.", $iWidht, $iHeight, $iLeft, $iTop)
GUISetBkColor(0xFFFFFF)

GUICtrlCreatePic(@ScriptDir & "\Bilder FS-Tool\wintop.jpg", 0, 0, 828, 52, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlCreatePic(@ScriptDir & "\Bilder FS-Tool\windown.jpg", 0, $iHeight-52, 828, 52, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$lblOrdnerPfad = GUICtrlCreateLabel("Ordnerpfad:", 16, 65, 100, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$inpPfad = GUICtrlCreateInput($sSearchPath, 120, 65, 649, 25)
GUICtrlSetFont(-1, 12, 600, 0, "MS Sans Serif")
GUICtrlSetState(-1, $Gui_Disable)
$butPfad = GUICtrlCreateButton(" ", 776, 55, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 5)

GUICtrlCreateGroup("Suchparameter", 16, 96, 473, 153)
$chbBestimmtAuflisten = GUICtrlCreateCheckbox("Bestimmte Dateien auflisten", 32, 120, 153, 17)
GUICtrlSetState(-1, $Gui_Disable)
$Combo1 = GUICtrlCreateCombo("Videos", 192, 120, 145, 25)
GUICtrlSetState(-1, $Gui_Disable)
GUICtrlSetData(-1, "Musik|Bilder", "Videos")
$chbBestimmtesFormat = GUICtrlCreateCheckbox("Nach bestimmtem Format Suchen", 32, 152, 177, 17)
GUICtrlSetState(-1, $Gui_Disable)
$inpBestimmt = GUICtrlCreateInput("txt", 216, 152, 30, 21)
GUICtrlSetState(-1, $Gui_Disable)
GUICtrlSetLimit(-1,4)
$chbFarbgebung = GUICtrlCreateCheckbox("Farbgebung Ein (Suche dauert länger!)", 32, 184, 300, 17)
GUICtrlSetState(-1, $Gui_Disable)
$inpSuchParameter = GUICtrlCreateInput("Alle Formate", 32, 216, 449, 21)
GUICtrlSetState(-1, $Gui_Disable)

GUICtrlCreateGroup("Suchinfos", 496, 96, 313, 153)
GUICtrlCreateLabel("Anzahl Files: ", 504, 120, 300, 17)
$lblAnzahl = GUICtrlCreateLabel("0", 600, 120, 100, 17)
GUICtrlCreateLabel("Gesammtgrösse: ", 504, 144, 300, 17)
$lblGroesse = GUICtrlCreateLabel("0 GB", 600, 144, 100, 17)
GUICtrlCreateLabel("Vergangene Zeit:", 504, 168, 300, 17)
$lblZeit = GUICtrlCreateLabel($HH & ":" & $MM & ":" & $SS, 600, 168, 100, 17)
GUICtrlCreateLabel("Status: ", 504, 192, 300, 17)
$lblStatushFSTool = GUICtrlCreateLabel("Ordnerpfad Wählen", 600, 192, 100, 17)
$Progress1 = GUICtrlCreateProgress(504, 216, 294, 17)
Global $hGIF = _GUICtrlCreateGIF($sFile, "", 700,120, -1, -1, 1)
GUICtrlSetState($hGIF, $GUI_HIDE)

$butAuflisten = GUICtrlCreateButton("Auflistung starten", 16, 249, 180, 40, 14, -1)
GUICtrlSetState(-1, $Gui_Disable)
$butBericht = GUICtrlCreateButton("Bericht", 195, 249, 100, 40, 14, -1)
GUICtrlSetState(-1, $Gui_Disable)
$butOeffnen = GUICtrlCreateButton("Öffnen",295,249,100,40,14,-1)
GUICtrlSetState(-1, $Gui_Disable)
$butMarkieren1 = GUICtrlCreateButton("Markieren",395,249,120,40,14,-1)
GUICtrlSetState(-1, $Gui_Disable)
$butInfo = GUICtrlCreateButton("Info", 515, 249, 80, 40, 14, -1)
GUICtrlSetState(-1, $Gui_Disable)
$butSearch1 = GUICtrlCreateButton("Suchen", 595, 249, 100, 40, 14, -1)
GUICtrlSetState(-1, $Gui_Disable)
$butListe = GUICtrlCreateButton("Liste", 695, 249, 110, 40, 14, -1)
GUICtrlSetState(-1, $Gui_Disable)

$ListView1 = GUICtrlCreateListView("Dateipfad|Dateiname|Format|Dateigrösse", 16, 290, 793, 275)
_GUICtrlListView_SetColumnWidth($ListView1, 0, 350)
_GUICtrlListView_SetColumnWidth($ListView1, 1, 240)
_GUICtrlListView_SetColumnWidth($ListView1, 2, 99)
_GUICtrlListView_SetColumnWidth($ListView1, 3, 100)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))

GUICtrlCreateLabel("",50, 575, 20, 20,Default,$WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x66FF66)
GUICtrlCreateLabel("",70, 575, 20, 20,Default,$WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0xAAFFAA)

GUICtrlCreateLabel("",250, 575, 20, 20,Default,$WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0xFF6666)
GUICtrlCreateLabel("",270, 575, 20, 20,Default,$WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0xFF9999)

GUICtrlCreateLabel("",450, 575, 20, 20,Default,$WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x6666FF)
GUICtrlCreateLabel("",470, 575, 20, 20,Default,$WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0x9999FF)

GUICtrlCreateLabel("",650, 575, 20, 20,Default,$WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("",670, 575, 20, 20,Default,$WS_EX_STATICEDGE)
GUICtrlSetBkColor(-1, 0xC0C0C0)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section FSTool###
#EndRegion ### END Koda GUI section FSTool###


#Region ### START Koda GUI section Markieren###
$hMarkieren = GUICreate("Markieren", 203, 325, 504, 263)
GUISetBkColor(0xFFFFFF)
GUICtrlCreatePic(@ScriptDir & "\Bilder FS-Tool\wintop.jpg", 0, 0, 203, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlCreatePic(@ScriptDir & "\Bilder FS-Tool\windown.jpg", 0, 325-42, 828, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$ChbVideos = GUICtrlCreateCheckbox("Videos", 24, 80, 97, 17)
$ChbMusik = GUICtrlCreateCheckbox("Musik", 24, 104, 97, 17)
$ChbBilder = GUICtrlCreateCheckbox("Bilder", 24, 128, 97, 17)
$ChbAlles = GUICtrlCreateCheckbox("Alles", 24, 152, 113, 17)
$ChbNichts = GUICtrlCreateCheckbox("Nichts", 24, 176, 80, 17)
$butMarkieren2 = GUICtrlCreateButton("Markieren", 32, 232, 131, 57, 14, -1)
GUICtrlCreateGroup("Auswahl", 16, 56, 161, 169)
$ChbBestimmte = GUICtrlCreateCheckbox("Bestimmte", 24, 200, 81, 17)
$inpMarkieren = GUICtrlCreateInput("txt", 112, 192, 49, 21)
GUICtrlSetState(-1, $Gui_Disable)
GUICtrlSetLimit(-1,4)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ProgressMarkieren = GUICtrlCreateProgress(16, 295, 166, 17)
#EndRegion ### END Koda GUI section Markieren###
#EndRegion ### END Koda GUI section Markieren###


#Region ### START Koda GUI section Suche###
$hSuche = GUICreate("Suche", 203, 300, 504, 638)
GUISetBkColor(0xFFFFFF)
GUICtrlCreatePic(@ScriptDir & "\Bilder FS-Tool\wintop.jpg", 0, 0, 203, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlCreatePic(@ScriptDir & "\Bilder FS-Tool\windown.jpg", 0, 300-42, 828, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlCreateGroup("Suchinfo", 16, 56, 161, 129)
GUICtrlCreateLabel("Übereinstimmungen: ", 20, 80, 100, 17)
$lblUebereinstimmungen = GUICtrlCreateLabel("0", 120, 80, 50, 17)
GUICtrlCreateLabel("Übertragen: ", 20, 105, 100, 17)
$lblUebertragen = GUICtrlCreateLabel("0", 120, 105, 50, 17)
GUICtrlCreateLabel("Vergangene Zeit: ", 20, 130, 100, 17)
$lblZeithSuche = GUICtrlCreateLabel("0:0:0", 120, 130, 50, 17)
GUICtrlCreateLabel("Status: ", 20, 155, 100, 17)
$lblStatushSuche = GUICtrlCreateLabel("Bereit", 120, 155, 50, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$inpSuchbefehl = GUICtrlCreateInput("Suchbefehl", 16, 192, 161, 21)
$butSearch2 = GUICtrlCreateButton("Suchen", 48, 224, 99, 40, 14, -1)
$ProgressSuche = GUICtrlCreateProgress(16, 270, 166, 17)
#EndRegion ### END Koda GUI section Suche###
#EndRegion ### END Koda GUI section Suche###


#Region ### START Koda GUI section Suche-Liste###
$hSucheListe = GUICreate("Suche - Liste", $iWidht, 232, 180, 178)
GUISetBkColor(0xFFFFFF)
GUICtrlCreatePic(@ScriptDir & "\Bilder FS-Tool\wintop.jpg", 0, 0, $iWidht, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlCreatePic(@ScriptDir & "\Bilder FS-Tool\windown.jpg", 0, 232-42, 828, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$ListView2 = GUICtrlCreateListView("Dateipfad|Dateiname|Format|Dateigrösse|Index", 16, 50, 793, 165)
_GUICtrlListView_SetColumnWidth($ListView2, 0, 300)
_GUICtrlListView_SetColumnWidth($ListView2, 1, 200)
_GUICtrlListView_SetColumnWidth($ListView2, 2, 99)
_GUICtrlListView_SetColumnWidth($ListView2, 3, 100)
_GUICtrlListView_SetColumnWidth($ListView2, 4, 90)
#EndRegion ### END Koda GUI section Suche-Liste###
#EndRegion ### END Koda GUI section Suche-Liste###


#Region ### START Koda GUI section Liste###
Local $Playlist, $ListViewPlaylist, $ButtonPInfo, $ButtonPSpeichern, $ButtonPAufrufen, $ButtonPKopieren, $ButtonPLeeren, $GroupUnbenannt, $ButtonPDown, $ButtonPUp
Local $ButtonPEinzelEntfernen, $ButtonPBeenden
$Playlist = GUICreate("Zwischenspeicher", 650, 632, @DesktopWidth / 2 - 650 / 2, @DesktopHeight / 2 - 532/ 2)
GUISetBkColor(0xFFFFFF)
GUICtrlCreatePic(@ScriptDir & "\Bilder FS-Tool\wintop.jpg", 0, 0, 650, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlCreatePic(@ScriptDir & "\Bilder FS-Tool\windown.jpg", 0, 632-42, 650, 42, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$ListViewPlaylist = GUICtrlCreateListView("Dateipfad|Dateiname|Format|Dateigrösse", 16, 66, 586, 474)
_GUICtrlListView_SetColumnWidth($ListViewPlaylist, 0, 232)
_GUICtrlListView_SetColumnWidth($ListViewPlaylist, 1, 200)
_GUICtrlListView_SetColumnWidth($ListViewPlaylist, 2, 50)
_GUICtrlListView_SetColumnWidth($ListViewPlaylist, 3, 100)
$ButtonPInfo = GUICtrlCreateButton("Info", 8, 558, 80, 40, 14, -1)
$ButtonPKopieren = GUICtrlCreateButton("Files Speichern", 90, 558, 150, 40, 14,-1)
$ButtonPEinzelEntfernen = GUICtrlCreateButton("Files Löschen", 242, 558, 150, 40, 14, -1)
$ButtonPLeeren = GUICtrlCreateButton("Leeren", 394, 558, 123, 40, 14, -1)
$ButtonPBeenden = GUICtrlCreateButton("Beenden", 519, 558, 123, 40, 14, -1)
$ButtonPDown = GUICtrlCreateButton("", 608, 318, 27, 25, BitOR($BS_BITMAP,$WS_GROUP))
GUICtrlSetImage(-1, @ScriptDir & "\Bilder FS-Tool\Down.bmp", -1)
$ButtonPUp = GUICtrlCreateButton("", 608, 286, 27, 25, BitOR($BS_BITMAP,$WS_GROUP))
GUICtrlSetImage(-1, @ScriptDir & "\Bilder FS-Tool\Up.bmp", -1)
#EndRegion ### END Koda GUI section Liste###
#EndRegion ### END Koda GUI section Liste###


#Region ### GDIPlus###
_GDIPlus_Startup ()
	$hGraphicFSTool = _GDIPlus_GraphicsCreateFromHWND ($hFSTool)
	$hBitmapFSTool = _GDIPlus_BitmapCreateFromGraphics($iWidht,$iHeight,$hGraphicFSTool)
	$hBackBufferFSTool = _GDIPlus_ImageGetGraphicsContext($hBitmapFSTool)

	$hGraphicMarkieren = _GDIPlus_GraphicsCreateFromHWND ($hMarkieren)
	$hBitmapMarkieren = _GDIPlus_BitmapCreateFromGraphics(203,325,$hGraphicMarkieren)
	$hBackBufferMarkieren = _GDIPlus_ImageGetGraphicsContext($hBitmapMarkieren)

	$hGraphicSuche = _GDIPlus_GraphicsCreateFromHWND ($hSuche)
	$hBitmapSuche = _GDIPlus_BitmapCreateFromGraphics(203,325,$hGraphicSuche)
	$hBackBufferSuche = _GDIPlus_ImageGetGraphicsContext($hBitmapSuche)

	$hGraphicSucheListe = _GDIPlus_GraphicsCreateFromHWND ($hSucheListe)
	$hBitmapSucheListe = _GDIPlus_BitmapCreateFromGraphics(203,325,$hGraphicSucheListe)
	$hBackBufferSucheListe = _GDIPlus_ImageGetGraphicsContext($hBitmapSucheListe)

	$hBrushTitel = _GDIPlus_BrushCreateSolid (0xFF393399)
	$hBrushDown = _GDIPlus_BrushCreateSolid (0xFF606060)
	$hFormat = _GDIPlus_StringFormatCreate ()
	$hFamily = _GDIPlus_FontFamilyCreate ("Arial")
	$hFontTitel = _GDIPlus_FontCreate ($hFamily, 18, 0)
	$hFontDown = _GDIPlus_FontCreate ($hFamily, 10, 0)

$tLayoutTitel1 = _GDIPlus_RectFCreate (10, 15, 0, 0)
$aInfoTitel1 = _GDIPlus_GraphicsMeasureString ($hGraphicFSTool, "Format-Search-Tool", $hFontTitel, $tLayoutTitel1, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($hGraphicFSTool, "Format-Search-Tool", $hFontTitel, $aInfoTitel1[0], $hFormat, $hBrushTitel)
$tLayoutDown1 = _GDIPlus_RectFCreate (95, 575, 0, 0)
$aInfoDown1 = _GDIPlus_GraphicsMeasureString ($hGraphicFSTool, "- Video Dateien", $hFontDown, $tLayoutDown1, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($hGraphicFSTool, "- Video Dateien", $hFontDown, $aInfoDown1[0], $hFormat, $hBrushDown)
$tLayoutDown2 = _GDIPlus_RectFCreate (295, 575, 0, 0)
$aInfoDown2 = _GDIPlus_GraphicsMeasureString ($hGraphicFSTool, "- Bild Dateien", $hFontDown, $tLayoutDown2, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($hGraphicFSTool, "- Bild Dateien", $hFontDown, $aInfoDown2[0], $hFormat, $hBrushDown)
$tLayoutDown3 = _GDIPlus_RectFCreate (495, 575, 0, 0)
$aInfoDown3 = _GDIPlus_GraphicsMeasureString ($hGraphicFSTool, "- Musik Dateien", $hFontDown, $tLayoutDown3, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($hGraphicFSTool, "- Musik Dateien", $hFontDown, $aInfoDown3[0], $hFormat, $hBrushDown)
$tLayoutDown4 = _GDIPlus_RectFCreate (695, 575, 0, 0)
$aInfoDown4 = _GDIPlus_GraphicsMeasureString ($hGraphicFSTool, "- Sonstige Dateien", $hFontDown, $tLayoutDown4, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($hGraphicFSTool, "- Sonstige Dateien", $hFontDown, $aInfoDown4[0], $hFormat, $hBrushDown)
#EndRegion ### GDIPlus###
#EndRegion ### GDIPlus###


Global $WinPos = WinGetPos($hFSTool)
Global $WinX = $WinPos[0]
Global $WinY = $WinPos[1]


If GUICtrlRead($inpPfad) <> "" Then
	GUICtrlSetState($chbBestimmtAuflisten, $Gui_Enable)
	GUICtrlSetState($chbBestimmtesFormat, $Gui_Enable)
	GUICtrlSetState($chbFarbgebung, $Gui_Enable)
	GUICtrlSetState($butAuflisten, $Gui_Enable)
	GUICtrlSetData($lblStatushFSTool, "Bereit" )
EndIf


AdlibRegister("_Check")


While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
		_Beenden()
;~ ------------------------------------------------------------------------------Start Cases $hFSTool
		Case $butPfad
			_SelectSearchpath()
		Case $butAuflisten
			_StartSearch()
		Case $butSearch1
			GUISetState(@SW_SHOW, $hSuche)
			WinMove($hSuche,"", $WinPos[0]+$iWidht+17, $WinPos[1])
			$tLayoutTitel3 = _GDIPlus_RectFCreate (10, 15, 0, 0)
			$aInfoTitel3 = _GDIPlus_GraphicsMeasureString ($hGraphicSuche, "Suchen", $hFontTitel, $tLayoutTitel3, $hFormat)
			_GDIPlus_GraphicsDrawStringEx ($hGraphicSuche, "Suchen", $hFontTitel, $aInfoTitel3[0], $hFormat, $hBrushTitel)
		Case $chbBestimmtesFormat
			If GUICtrlRead($chbBestimmtesFormat) = 1 Then
				GUICtrlSetState($chbBestimmtAuflisten, $Gui_Unchecked)
				GUICtrlSetState($Combo1, $Gui_Disable)
				GUICtrlSetData($inpSuchParameter, ".+\." & GUICtrlRead($inpBestimmt))
				GUICtrlSetState($inpBestimmt, $Gui_Enable)
			Else
				GUICtrlSetData($inpSuchParameter, "Alle Formate")
				GUICtrlSetState($inpBestimmt, $Gui_Disable)
			EndIf
		Case $chbBestimmtAuflisten
			If GUICtrlGetState($Combo1) = 144 Then
				GUICtrlSetState($Combo1, $Gui_Enable)
				GUICtrlSetState($chbBestimmtesFormat, $Gui_Unchecked)
				GUICtrlSetState($inpBestimmt, $Gui_Disable)
				GUICtrlSetData($inpSuchParameter, "")
				If GUICtrlRead($Combo1) = "Videos" Then
					GUICtrlSetData($inpSuchParameter,$VideoFormate)
				ElseIf GUICtrlRead($Combo1) = "Musik" Then
					GUICtrlSetData($inpSuchParameter,$MusikFormate)
				ElseIf GUICtrlRead($Combo1) = "Bilder" Then
					GUICtrlSetData($inpSuchParameter,$BildFormate)
				EndIf
			Else
				GUICtrlSetState($Combo1, $Gui_Disable)
				GUICtrlSetData($inpSuchParameter, "Alle Formate")
			EndIf
		Case $Combo1
			GUICtrlSetData($inpSuchParameter,"")
			If GUICtrlRead($Combo1) = "Videos" Then
				GUICtrlSetData($inpSuchParameter,$VideoFormate)
			ElseIf GUICtrlRead($Combo1) = "Musik" Then
				GUICtrlSetData($inpSuchParameter,$MusikFormate)
			ElseIf GUICtrlRead($Combo1) = "Bilder" Then
				GUICtrlSetData($inpSuchParameter,$BildFormate)
			EndIf
		Case $butBericht
			_BerichtText(0)
		Case $butOeffnen
			$ItemSelect = _GUICtrlListView_GetNextItem($ListView1)
			$aItem = _GUICtrlListView_GetItemTextArray($ListView1, $ItemSelect)
			$sText = $aItem[1] & $aItem[2] & "." & $aItem[3]
			If Not $sText = "" Then
				ShellExecute($sText,"","","open")
				$sText = ""
			EndIf
		Case $butInfo
			$ItemSelect = _GUICtrlListView_GetNextItem($ListView1)
			$aItem = _GUICtrlListView_GetItemTextArray($ListView1, $ItemSelect)
			$sText = $aItem[1] & $aItem[2] & "." & $aItem[3]
			If Not $sText = "" Then
				_FileProperties($sText)
				$sText = ""
			EndIf
		Case $butMarkieren1
			GUISetState(@SW_SHOW, $hMarkieren)
			WinMove($hMarkieren,"", $WinPos[0]-220, $WinPos[1])
			$tLayoutTitel2 = _GDIPlus_RectFCreate (10, 15, 0, 0)
			$aInfoTitel2 = _GDIPlus_GraphicsMeasureString ($hGraphicMarkieren, "Markieren", $hFontTitel, $tLayoutTitel2, $hFormat)
			_GDIPlus_GraphicsDrawStringEx ($hGraphicMarkieren, "Markieren", $hFontTitel, $aInfoTitel2[0], $hFormat, $hBrushTitel)
		Case $butListe
			GUISetState(@SW_SHOW, $Playlist)
			_State($Gui_Disable)
			Local $i, $aItem, $sText, $ItemSelect
			For $p = 0 To _GUICtrlListView_GetItemCount($ListView1) - 1
				If _GUICtrlListView_GetItemChecked($ListView1, $p) = True Then
					$aItem = _GUICtrlListView_GetItemTextArray($ListView1, $p)
					$Item = GUICtrlCreateListViewItem($aItem[1] & "|" & $aItem[2] & "|" & $aItem[3] & "|" & $aItem[4] ,$ListViewPlaylist)
					_GUICtrlListView_SetItemChecked($ListView1, $p, False)
					$sText = ""
				EndIf
			Next
			_State($Gui_Enable)
;~ ------------------------------------------------------------------------------Start Cases $hMarkieren
		Case $ChbAlles
			GUICtrlSetState($ChbBestimmte, $Gui_Unchecked)
			GUICtrlSetState($ChbVideos, $Gui_Unchecked)
			GUICtrlSetState($ChbMusik, $Gui_Unchecked)
			GUICtrlSetState($ChbBilder, $Gui_Unchecked)
			GUICtrlSetState($ChbNichts, $Gui_Unchecked)
			GUICtrlSetState($inpMarkieren, $Gui_Disable)
		Case $ChbBestimmte
			GUICtrlSetState($ChbAlles, $Gui_Unchecked)
			GUICtrlSetState($ChbNichts, $Gui_Unchecked)
			If GUICtrlRead($ChbBestimmte) = 1 Then
				GUICtrlSetState($inpMarkieren, $Gui_Enable)
			Else
				GUICtrlSetState($inpMarkieren, $Gui_Disable)
			EndIf
		Case $ChbVideos
			GUICtrlSetState($ChbAlles, $Gui_Unchecked)
			GUICtrlSetState($ChbNichts, $Gui_Unchecked)
		Case $ChbMusik
			GUICtrlSetState($ChbAlles, $Gui_Unchecked)
			GUICtrlSetState($ChbNichts, $Gui_Unchecked)
		Case $ChbBilder
			GUICtrlSetState($ChbAlles, $Gui_Unchecked)
			GUICtrlSetState($ChbNichts, $Gui_Unchecked)
		Case $ChbNichts
			GUICtrlSetState($ChbBestimmte, $Gui_Unchecked)
			GUICtrlSetState($ChbVideos, $Gui_Unchecked)
			GUICtrlSetState($ChbMusik, $Gui_Unchecked)
			GUICtrlSetState($ChbBilder, $Gui_Unchecked)
			GUICtrlSetState($ChbAlles, $Gui_Unchecked)
			GUICtrlSetState($inpMarkieren, $Gui_Disable)
		Case $butMarkieren2
			_Markieren()
;~ ------------------------------------------------------------------------------Start Cases $hSuche
		Case $butSearch2
			AdlibRegister("_TimeSearch",10)
			GUICtrlSetData($lblUebereinstimmungen, 0)
			GUICtrlSetData($lblUebertragen, 0)
			$HH = 0
			$MM = 0
			$SS = 0
			GUICtrlSetData($lblStatushSuche, "Durchsuchen...")
			$Index = -1
			$Uebereinstimmungen = 0
			GUICtrlSetData($ProgressSuche,0)
			_GUICtrlListView_BeginUpdate($ListView2)
			_GUICtrlListView_DeleteAllItems($ListView2)
			_GUICtrlListView_EndUpdate($ListView2)
			_State($Gui_Disable)
			WinMove($hSucheListe,"",$WinPos[0], $WinPos[1] - 270)
			GUISetState(@SW_SHOW, $hSucheListe)
			$tLayoutTitel4 = _GDIPlus_RectFCreate (10, 15, 0, 0)
			$aInfoTitel4 = _GDIPlus_GraphicsMeasureString ($hGraphicSucheListe, "Suchergebnis", $hFontTitel, $tLayoutTitel4, $hFormat)
			_GDIPlus_GraphicsDrawStringEx ($hGraphicSucheListe, "Suchergebnis", $hFontTitel, $aInfoTitel4[0], $hFormat, $hBrushTitel)
			For $s = 0 To _GUICtrlListView_GetItemCount($ListView1)
				If $Abbruchcode = 1 Then
					ExitLoop
				EndIf
				$iL = _GUICtrlListView_FindInText($ListView1, GUICtrlRead($inpSuchbefehl),$Index)
				If $iL < $Index  And $Index > -1 Then ExitLoop
				If $iL = -1 Then
					MsgBox(16,GUICtrlRead($inpSuchbefehl),"<" & GUICtrlRead($inpSuchbefehl) & "> konnte nicht gefunden werden. Stellen Sie sicher, dass Sie den Namen richtig eingegeben haben und wiederholen Sie den Vorgang.")
					ExitLoop
				Else
					$aItem = _GUICtrlListView_GetItemTextArray($ListView1, $iL)
					$Index = $iL
					GUICtrlCreateListViewItem($aItem[1] & "|" & $aItem[2] & "|" & $aItem[3] &  "|" & $aItem[4] & "|" & $Index,$ListView2)
					GUICtrlSetData($ProgressSuche, $Index *100/_GUICtrlListView_GetItemCount($ListView1))
					$Uebereinstimmungen += 1
					GUICtrlSetData($lblUebereinstimmungen, $Uebereinstimmungen)
					GUICtrlSetData($lblUebertragen, _GUICtrlListView_GetItemCount($ListView2))
				EndIf
			Next
			GUICtrlSetData($ProgressSuche,100)
			_State($Gui_Enable)
			$Abbruchcode = 0
			GUICtrlSetData($lblStatushSuche, "Bereit")
			AdlibUnRegister("_TimeSearch")
;~ ------------------------------------------------------------------------------Start Cases $Playlist
			Case $ButtonPBeenden
				GUISetState(@SW_HIDE, $Playlist)
			Case $ButtonPLeeren
				_State($Gui_Disable)
				_GUICtrlListView_DeleteAllItems($ListViewPlaylist)
				_State($Gui_Enable)
			Case $ButtonPUp
				$Item1 = _GUICtrlListView_GetNextItem($ListViewPlaylist)
				$Item2 = (_GUICtrlListView_GetNextItem($ListViewPlaylist)) - 1
				$Item1Name = _GUICtrlListView_GetItemTextArray($ListViewPlaylist, $Item1)
				$Item2Name = _GUICtrlListView_GetItemTextArray($ListViewPlaylist, $Item2)
				If $Item1 > 0 Then
					_GUICtrlListView_SetItemText($ListViewPlaylist, $Item2, $Item1Name[1])
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item2, $Item1Name[2],1)
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item2, $Item1Name[3],2)
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item2, $Item1Name[4],3)
					_GUICtrlListView_SetItemText($ListViewPlaylist, $Item1, $Item2Name[1])
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item1, $Item2Name[2],1)
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item1, $Item2Name[3],2)
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item1, $Item2Name[4],3)
					_GUICtrlListView_SetItemSelected($ListViewPlaylist, $Item2)
					_GUICtrlListView_ClickItem($ListViewPlaylist,$Item2)
				EndIf
				$Item1 = 0
				$Item2 = 0
				$Item1Name = 0
				$Item2Name = 0
			Case $ButtonPDown
				$Item1 = _GUICtrlListView_GetNextItem($ListViewPlaylist)
				$Item2 = (_GUICtrlListView_GetNextItem($ListViewPlaylist)) + 1
				$Item1Name = _GUICtrlListView_GetItemTextArray($ListViewPlaylist, $Item1)
				$Item2Name = _GUICtrlListView_GetItemTextArray($ListViewPlaylist, $Item2)
				If $Item1 < (_GUICtrlListView_GetItemCount($ListViewPlaylist)) - 1 Then
					_GUICtrlListView_SetItemText($ListViewPlaylist, $Item2, $Item1Name[1])
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item2, $Item1Name[2],1)
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item2, $Item1Name[3],2)
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item2, $Item1Name[4],3)
					_GUICtrlListView_SetItemText($ListViewPlaylist, $Item1, $Item2Name[1])
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item1, $Item2Name[2],1)
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item1, $Item2Name[3],2)
					_GUICtrlListView_AddSubItem($ListViewPlaylist, $Item1, $Item2Name[4],3)
					_GUICtrlListView_SetItemSelected($ListViewPlaylist, $Item2)
					_GUICtrlListView_ClickItem($ListViewPlaylist,$Item2)
				EndIf
				$Item1 = 0
				$Item2 = 0
				$Item1Name = 0
				$Item2Name = 0
			Case $ButtonPInfo
				_State($Gui_Disable)
				Local $aItem, $sText, $Zwischenspeichergroesse, $Kopierdauer
				$Zwischenspeichergroesse = 0
				For $p = 0 To _GUICtrlListView_GetItemCount($ListViewPlaylist) - 1
					$aItem = _GUICtrlListView_GetItemTextArray($ListViewPlaylist, $p)
					$sText = $aItem[1] & $aItem[2] & "." & $aItem[3]
					$Zwischenspeichergroesse = $Zwischenspeichergroesse + FileGetSize($sText)
					$sText = ""
				Next
				$Zwischenspeichergroesse = Round($Zwischenspeichergroesse / 1024 / 1024,2)
				$Kopierdauer = Round($Zwischenspeichergroesse / 30,2)
				#Region --- CodeWizard generated code Start ---
				;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info
				MsgBox(64,"Info","Anzahl Files: " & _GUICtrlListView_GetItemCount($ListViewPlaylist) & @CRLF & _
				@CRLF & "Gesammtgrösse: " & $Zwischenspeichergroesse & "MB" & @CRLF & _
				@CRLF & "Ungefähre Kopierdauer (bei 30MB/Sekunde): ~" & $Kopierdauer & "Sek." & @CRLF & _
				@CRLF & "Die Zeitangabe kann sehr variieren und Ungenau sein!")
				#EndRegion --- CodeWizard generated code End ---
				_State($Gui_Enable)
			Case $ButtonPKopieren
				Kopie()
			Case $ButtonPEinzelEntfernen
				Loeschen()
	EndSwitch
WEnd


Func _SelectSearchpath()
	Local $sPath
	$sPath = FileSelectFolder('Bitte Verzeichnis auswählen', @DesktopDir, 2, $sSearchPath, $hFSTool)
	If @error Then Return
	If FileExists($sPath) Then
		$sSearchPath = $sPath
		If StringRight($sSearchPath, 1) <> '\' Then $sSearchPath &= '\'
		GUICtrlSetData($inpPfad, $sSearchPath)
		GUICtrlSetState($chbBestimmtAuflisten, $Gui_Enable)
		GUICtrlSetState($chbBestimmtesFormat, $Gui_Enable)
		GUICtrlSetState($chbFarbgebung, $Gui_Enable)
		GUICtrlSetState($butAuflisten, $Gui_Enable)
		IniWrite($sIniPath, 'Prefs', 'SearchPath', $sSearchPath)
	Else
		_PlayDefaultSystemSound('SystemAsterisk')
		GUICtrlSetData($inpPfad, "Ungültiger Ordnerpfad!")
		GUICtrlSetState($chbBestimmtAuflisten, $Gui_Disable)
		GUICtrlSetState($Combo1, $Gui_Disable)
		GUICtrlSetState($chbBestimmtesFormat, $Gui_Disable)
		GUICtrlSetState($chbFarbgebung, $Gui_Disable)
		GUICtrlSetState($butAuflisten, $Gui_Disable)
		GUICtrlSetState($butBericht, $Gui_Disable)
	EndIf
EndFunc


Func _PlayDefaultSystemSound($sSoundName, $iWait = 0)
	Local $sKey = 'HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default'
	If $sSoundName = 'EmptyRecycleBin' Or $sSoundName = 'Navigating' Then $sKey = 'HKEY_CURRENT_USER\AppEvents\Schemes\Apps\Explorer'
	Local $sFile = StringReplace(RegRead($sKey & '\' & $sSoundName & '\.Default', ''), '%SystemRoot%', @WindowsDir)
	If $sFile = "" Then
		SoundPlay(StringReplace(RegRead($sKey & '\.Default\.Default', ''), '%SystemRoot%', @WindowsDir), $iWait)
	Else
		SoundPlay($sFile, $iWait)
	EndIf
EndFunc


Func _StartSearch()
	$Text = ""
	$SS = 0
	$MM = 0
	$HH = 0
	$AnzahlFiles = 0
	$Volumen = 0
	$Fortschritt = 0
	GUICtrlSetData($lblAnzahl,$AnzahlFiles )
	GUICtrlSetData($lblGroesse,Round(($Volumen/1024/1024/1024),2) & " GB")
	GUICtrlSetData($Progress1, 0)

	$Init = TimerInit()
	_Time("Auslesen",0)
	_State($Gui_Disable)
	GUICtrlSetData($lblStatushFSTool, "Liste Leeren" )
	_ClearListView()
	GUICtrlSetData($lblStatushFSTool, "Daten Auslesen" )
	If GUICtrlRead($inpSuchParameter) = "Alle Formate" Then
		$aDateien = _RecursiveFileListToArray($sSearchPath, '.+\.*', 1, 1)
		GUICtrlSetData($lblAnzahl,$AnzahlFiles )
		GUICtrlSetData($lblGroesse,Round(($Volumen/1024/1024/1024),2) & " GB")
		GUICtrlSetData($lblStatushFSTool, "aufgelistet: 0")
		GUICtrlSetData($Progress1, 20)
		For $a = 1 To $aDateien[0]
			If $Abbruchcode = 1 Or _GUICtrlListView_GetItemCount($ListView1) = 65000 Then
				MsgBox(16,"Error", "Die Auflistung wurde entweder unterbrochen oder das Fassungsvermögen der Liste (65000 elemente) ist erreicht.")
				ExitLoop
			EndIf
			$Name = StringSplit($aDateien[$a], "\")
			$len = StringLen($Name[$Name[0]])
			$pfad = StringTrimRight($aDateien[$a], $len)
			$Format = StringSplit($Name[$Name[0]], ".")
			$Item = GUICtrlCreateListViewItem($pfad & "|" & StringTrimRight($Name[$Name[0]],StringLen($Format[$Format[0]])+1) & "|" & $Format[$Format[0]] &  "|" & Round((FileGetSize($aDateien[$a])/1024/1024),2) & "MB",$ListView1)
			If GUICtrlRead($chbFarbgebung) = 1 Then
				_Color($Format[$Format[0]],$Item)
			EndIf
			$Fortschritt += 80/($aDateien[0]-1)
			_Time("Auflisten",$a)
			GUICtrlSetData($Progress1, 20 + $Fortschritt)
		Next
		GUICtrlSetData($Progress1, 100)
		GUICtrlSetData($lblStatushFSTool, "aufgelistet: " & $a)
	Else
		$Formate = StringSplit(GUICtrlRead($inpSuchParameter),";")
		For $f = 1 To $Formate[0]
			If $Abbruchcode = 1 Then
				ExitLoop
			EndIf
			$Fortschritt = 0
			$aDateien = _RecursiveFileListToArray($sSearchPath, $Formate[$f], 1, 1)
			GUICtrlSetData($lblAnzahl,$AnzahlFiles )
			GUICtrlSetData($lblGroesse,Round(($Volumen/1024/1024/1024),2) & " GB")
			GUICtrlSetData($lblStatushFSTool, "aufgelistet: 0")
			GUICtrlSetData($Progress1, 20)
			For $a = 1 To $aDateien[0]
				If $Abbruchcode = 1  Or _GUICtrlListView_GetItemCount($ListView1) = 65000 Then
					MsgBox(16,"Error", "Die Auflistung wurde entweder unterbrochen oder das Fassungsvermögen der Liste (65000 elemente) ist erreicht.")
					ExitLoop
				EndIf
				$Name = StringSplit($aDateien[$a], "\")
				$len = StringLen($Name[$Name[0]])
				$pfad = StringTrimRight($aDateien[$a], $len)
				$Format = StringSplit($Name[$Name[0]], ".")
				$Item = GUICtrlCreateListViewItem($pfad & "|" & StringTrimRight($Name[$Name[0]],StringLen($Format[$Format[0]])+1) & "|" & $Format[$Format[0]] &  "|" & Round((FileGetSize($aDateien[$a])/1024/1024),2) & "MB",$ListView1)
				If GUICtrlRead($chbFarbgebung) = 1 Then
					_Color($Format[$Format[0]],$Item)
				EndIf
				$Fortschritt += 80/($aDateien[0]-1)
				_Time("Auflisten",$a)
				GUICtrlSetData($Progress1, 20 + $Fortschritt)
			Next
			$VolumenEinzel = 0
			$AnzahlEinzel = 0
		Next
		GUICtrlSetData($Progress1, 100)
		GUICtrlSetData($lblStatushFSTool, "aufgelistet: " & $a)
	EndIf
	GUICtrlSetData($lblStatushFSTool, "Bericht erstellen" )
	_BerichtText(1)
	_State($Gui_Enable)
	GUICtrlSetState($butBericht, $Gui_Enable)
	$Abbruchcode = 0
	GUICtrlSetData($lblStatushFSTool, "Bereit" )
EndFunc


Func _ClearListView()
	_GUICtrlListView_BeginUpdate($ListView1)
	_GUICtrlListView_DeleteAllItems($ListView1)
	_GUICtrlListView_EndUpdate($ListView1)
EndFunc


Func _RecursiveFileListToArray($sPath, $sPattern = '', $iFlag = 0, $iFormat = 1, $iRecursion = 1, $sDelim = @CRLF)
	Local $hSearch, $sFile, $sReturn = ''
	If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
	$hSearch = FileFindFirstFile($sPath & '*.*')
	If @error Or $hSearch = -1 Then Return SetError(1, 0, $sReturn)
	While True
		$sFile = FileFindNextFile($hSearch)
		If @error Then ExitLoop
		If @extended Then
			If StringRegExp($sPath & $sFile, $sPattern) And ($iFlag = 0 Or $iFlag = 2) Then $sReturn &= $sPath & $sFile & '\' & $sDelim
			If $iRecursion Then $sReturn &= _RecursiveFileListToArray($sPath & $sFile & '\', $sPattern, $iFlag, 0)
			ContinueLoop
		EndIf
		If StringRegExp($sFile, $sPattern) And ($iFlag = 0 Or $iFlag = 1) Then
		$sReturn &= $sPath & $sFile & $sDelim
		$AnzahlFiles = $AnzahlFiles + 1
		$AnzahlEinzel = $AnzahlEinzel + 1
		$Volumen = $Volumen + FileGetSize($sPath & $sFile)
		$VolumenEinzel = $VolumenEinzel + FileGetSize($sPath & $sFile)
		_Time("Auslesen",0)
		EndIf
		$AktuellerPfad = $sPath
		If $Abbruchcode = 1 Then
			ExitLoop
		EndIf
	WEnd
	_Time("Auslesen",0)
	FileClose($hSearch)
	If $iFormat And $sReturn = '' Then Return StringSplit($sReturn, '', $iFormat)
	If $iFormat Then Return StringSplit(StringTrimRight($sReturn, StringLen($sDelim)), $sDelim, $iFormat)
	Return $sReturn
EndFunc


Func _Time($zStatus,$a)
	$Diff += TimerDiff($Init)
	If $Diff >=1000 Then
		If $SS = 59 Then
			If $MM = 59 Then
				$HH += 1
				$MM = 0
				$SS = 0
			Else
				$MM += 1
				$SS = 0
			EndIf
		Else
			$SS += 1
		EndIf
		If $zStatus = "Search" Then
			GUICtrlSetData($lblZeithSuche, $HH & ":" & $MM & ":" & $SS)
		Else
			GUICtrlSetData($lblZeit, $HH & ":" & $MM & ":" & $SS)
		EndIf
		If $zStatus = "Auslesen" Then
			GUICtrlSetData($lblAnzahl,$AnzahlFiles )
			GUICtrlSetData($lblGroesse,Round(($Volumen/1024/1024/1024),2) & " GB")
			GUICtrlSetData($Progress1, GUICtrlRead($Progress1) + 1)
		ElseIf $zStatus = "Auflisten" Then
			GUICtrlSetData($lblStatushFSTool, "aufgelistet: " & $a)
		EndIf
		$Diff = 0
	EndIf
	$Init = TimerInit()
EndFunc


Func _State($State)
	If $State = $Gui_Disable Then
		GUICtrlSetState($hGIF, $GUI_Show)
		GUICtrlSetData($butAuflisten,"Mit ESC abbrechen")
	Else
		GUICtrlSetState($hGIF, $GUI_HIDE)
		GUICtrlSetData($butAuflisten,"Auflistung starten")
	EndIf
	GUICtrlSetState($butAuflisten, $State)
	GUICtrlSetState($chbBestimmtAuflisten, $State)
	GUICtrlSetState($chbBestimmtesFormat, $State)
	GUICtrlSetState($chbFarbgebung, $State)
	GUICtrlSetState($butSearch1, $State)
	GUICtrlSetState($butPfad, $State)
	GUICtrlSetState($butBericht, $State)
	GUICtrlSetState($butMarkieren1, $State)
	GUICtrlSetState($butListe, $State)
	GUICtrlSetState($ChbVideos, $State)
	GUICtrlSetState($ChbMusik, $State)
	GUICtrlSetState($ChbBilder, $State)
	GUICtrlSetState($ChbAlles, $State)
	GUICtrlSetState($ChbNichts, $State)
	GUICtrlSetState($ChbBestimmte, $State)
	GUICtrlSetState($inpMarkieren, $State)
	GUICtrlSetState($butMarkieren2, $State)
	GUICtrlSetState($inpSuchbefehl, $State)
	GUICtrlSetState($butSearch2, $State)
	GUICtrlSetState($ListView2, $State)
	GUICtrlSetState($ListViewPlaylist, $State)
	GUICtrlSetState($ButtonPInfo, $State)
	GUICtrlSetState($ButtonPKopieren, $State)
	GUICtrlSetState($ButtonPEinzelEntfernen, $State)
	GUICtrlSetState($ButtonPLeeren, $State)
	GUICtrlSetState($ButtonPBeenden, $State)
	GUICtrlSetState($ButtonPDown, $State)
	GUICtrlSetState($ButtonPUp, $State)
EndFunc


Func _Color($Endung,$Item)
	If $ColorSwitch = 0 Then
		$ColorSwitch = 1
		If $Endung = "avi" Or $Endung = "flv" Or $Endung = "mp4" Or $Endung = "mkv" Then
			GUICtrlSetBkColor($Item, 0x66FF66)
		ElseIf $Endung = "mp3" Or $Endung = "m4a" Or $Endung = "aac" Or $Endung = "wav" Or $Endung = "wma" Then
			GUICtrlSetBkColor($Item, 0x6666FF)
		ElseIf $Endung = "jpg" Or $Endung = "bmp" Or $Endung = "png" Then
			GUICtrlSetBkColor($Item, 0xFF6666)
		Else
			GUICtrlSetBkColor($Item, 0xFFFFFF)
		EndIf
	Else
		$ColorSwitch = 0
		If $Endung = "avi" Or $Endung = "flv" Or $Endung = "mp4" Or $Endung = "mkv" Then
			GUICtrlSetBkColor($Item, 0xAAFFAA)
		ElseIf $Endung = "mp3" Or $Endung = "m4a" Or $Endung = "aac" Or $Endung = "wav" Or $Endung = "wma" Then
			GUICtrlSetBkColor($Item, 0x9999FF)
		ElseIf $Endung = "jpg" Or $Endung = "bmp" Or $Endung = "png" Then
			GUICtrlSetBkColor($Item, 0xFF9999)
		Else
			GUICtrlSetBkColor($Item, 0xC0C0C0)
		EndIf
	EndIf
EndFunc


Func _BerichtText($Write)
	$Fortschritt = 0
	If $Write = 1 Then
		GUICtrlSetData($Progress1,0)
		Global $AnzVideos = 0
		Global $AnzMusik = 0
		Global $AnzBilder = 0
		Global $AnzSonstige = 0
		Global $SizeVideos = 0
		Global $SizeMusik = 0
		Global $SizeBilder = 0
		Global $SizeSonstige = 0
		For $m = 0 To _GUICtrlListView_GetItemCount($ListView1)-1
			If $Abbruchcode = 1 Then
				ExitLoop
			EndIf
			$aItem = _GUICtrlListView_GetItemTextArray($ListView1, $m)
			If $aItem[3] = "avi" Or $aItem[3] = "flv" Or $aItem[3] = "mp4" Or $aItem[3] = "mkv" Then
				$AnzVideos += 1
				$SizeVideos += FileGetSize($aItem[1] & $aItem[2] & "." & $aItem[3])
			ElseIf $aItem[3] = "mp3" Or $aItem[3] = "m4a" Or $aItem[3] = "aac" Or $aItem[3] = "wav" Or $aItem[3] = "wma" Then
				$AnzMusik += 1
				$SizeMusik += FileGetSize($aItem[1] & $aItem[2] & "." & $aItem[3])
			ElseIf $aItem[3] = "jpg" Or $aItem[3] = "bmp" Or $aItem[3] = "png" Then
				$AnzBilder += 1
				$SizeBilder += FileGetSize($aItem[1] & $aItem[2] & "." & $aItem[3])
			Else
				$AnzSonstige +=1
				$SizeSonstige += FileGetSize($aItem[1] & $aItem[2] & "." & $aItem[3])
			EndIf
			$Fortschritt +=(100/_GUICtrlListView_GetItemCount($ListView1))
			GUICtrlSetData($Progress1, $Fortschritt)
			_Time("","")
		Next
		GUICtrlSetData($Progress1, 100)
		$Text = ("Anzahl Videodateien: " & $AnzVideos & @CRLF & "Grösse: " & Round(($SizeVideos/1024/1024/1024),2) & " GB" & @CRLF & @CRLF & "Anzahl Musikdateien: " & $AnzMusik & @CRLF & "Grösse: " & Round(($SizeMusik/1024/1024/1024),2) & " GB" & @CRLF & @CRLF & "Anzahl Bilddateien: " & $AnzBilder & @CRLF & "Grösse: " & Round(($SizeBilder/1024/1024/1024),2) & " GB" & @CRLF & @CRLF & "Anzahl sonstige Dateien: " & $AnzSonstige & @CRLF & "Grösse: " & Round(($SizeSonstige/1024/1024/1024),2) & " GB")
		MsgBox(0,"",$Text)
	Else
		MsgBox(0,"",$Text)
	EndIf
EndFunc


Func _Check()
	If GUICtrlRead($ListView1) <> 0 Then
		GUICtrlSetState($butOeffnen, $Gui_Enable)
		GUICtrlSetState($butInfo, $Gui_Enable)
	ElseIf GUICtrlRead($ListView1) = 0 Then
		GUICtrlSetState($butOeffnen, $Gui_Disable)
		GUICtrlSetState($butInfo, $Gui_Disable)
	EndIf
	Global $WinPos = WinGetPos($hFSTool)
	If $WinX <> $WinPos[0] Then
		Global $WinX = $WinPos[0]
		Global $WinY = $WinPos[1]
		WinMove($hMarkieren,"", $WinPos[0]-220, $WinPos[1])
		WinMove($hSuche,"", $WinPos[0]+$iWidht+17, $WinPos[1])
		WinMove($hSucheListe,"",$WinPos[0], $WinPos[1] - 270)
	EndIf
	If GUICtrlRead($ChbVideos) <> 1 And GUICtrlRead($ChbMusik) <> 1 And GUICtrlRead($ChbBilder) <> 1 And GUICtrlRead($ChbAlles) <> 1 And GUICtrlRead($ChbNichts) <> 1 And GUICtrlRead($ChbBestimmte) <> 1 Then
		GUICtrlSetState($butMarkieren2, $Gui_Disable)
	Else
		GUICtrlSetState($butMarkieren2, $Gui_Enable)
	EndIf
	If GUICtrlRead($inpSuchbefehl) = "" Then
		GUICtrlSetState($butSearch2, $Gui_Disable)
	Else
		GUICtrlSetState($butSearch2, $Gui_Enable)
	EndIf
	If GUICtrlRead($ListView2) <> 0 And $ItemSelect <> _GUICtrlListView_GetNextItem($ListView2) Then
		$ItemSelect = _GUICtrlListView_GetNextItem($ListView2)
		$aItem = _GUICtrlListView_GetItemTextArray($ListView2, $ItemSelect)
		_GUICtrlListView_SetItemSelected($ListView1, $aItem[5])
		_GUICtrlListView_ClickItem($ListView1,$aItem[5])
	EndIf
EndFunc


Func _FileProperties($sText)
	$oShellApp.namespace(0).parsename($sText).invokeverb('Properties')
EndFunc


Func _Markieren()
	GUICtrlSetData($lblStatushFSTool, "Markieren" )
	_State($Gui_Disable)
	$BerichtMarkieren = 0
	$SS = 0
	$MM = 0
	$HH = 0
	$Fortschritt = 0
	If GUICtrlRead($ChbAlles) = 1 Then
		GUICtrlSetData($ProgressMarkieren, 0)
		For $m = 0 To _GUICtrlListView_GetItemCount($ListView1)-1
			If $Abbruchcode = 1 Then
				ExitLoop
			EndIf
			_GUICtrlListView_SetItemChecked($ListView1, $m, True)
			$Fortschritt +=(100/_GUICtrlListView_GetItemCount($ListView1))
			GUICtrlSetData($ProgressMarkieren, $Fortschritt)
			$BerichtMarkieren += 1
			_Time("","")
		Next
	ElseIf GUICtrlRead($ChbNichts) = 1 Then
		GUICtrlSetData($ProgressMarkieren, 0)
		For $m = 0 To _GUICtrlListView_GetItemCount($ListView1)-1
			If $Abbruchcode = 1 Then
				ExitLoop
			EndIf
			_GUICtrlListView_SetItemChecked($ListView1, $m, False)
			$Fortschritt += (100/_GUICtrlListView_GetItemCount($ListView1))
			GUICtrlSetData($ProgressMarkieren, $Fortschritt)
			$BerichtMarkieren += 1
			_Time("","")
		Next
	EndIf
	If GUICtrlRead($ChbVideos) = 1 Then
		GUICtrlSetData($ProgressMarkieren, 0)
		For $m = 0 To _GUICtrlListView_GetItemCount($ListView1)-1
			If $Abbruchcode = 1 Then
				ExitLoop
			EndIf
			$aItem = _GUICtrlListView_GetItemTextArray($ListView1, $m)
			If $aItem[3] = "avi" Or $aItem[3] = "flv" Or $aItem[3] = "mp4" Or $aItem[3] = "mkv" Then
				_GUICtrlListView_SetItemChecked($ListView1, $m, True)
				$BerichtMarkieren += 1
			EndIf
			$Fortschritt += (100/_GUICtrlListView_GetItemCount($ListView1))
			GUICtrlSetData($ProgressMarkieren, $Fortschritt)
			_Time("","")
		Next
	EndIf
	If GUICtrlRead($ChbMusik) = 1 Then
		GUICtrlSetData($ProgressMarkieren, 0)
		For $m = 0 To _GUICtrlListView_GetItemCount($ListView1)-1
			If $Abbruchcode = 1 Then
				ExitLoop
			EndIf
			$aItem = _GUICtrlListView_GetItemTextArray($ListView1, $m)
			If $aItem[3] = "mp3" Or $aItem[3] = "m4a" Or $aItem[3] = "aac" Or $aItem[3] = "wav" Or $aItem[3] = "wma" Then
				_GUICtrlListView_SetItemChecked($ListView1, $m, True)
				$BerichtMarkieren += 1
			EndIf
			$Fortschritt += (100/_GUICtrlListView_GetItemCount($ListView1))
			GUICtrlSetData($ProgressMarkieren, $Fortschritt)
			_Time("","")
		Next
	EndIf
	If GUICtrlRead($ChbBilder) = 1 Then
		GUICtrlSetData($ProgressMarkieren, 0)
		For $m = 0 To _GUICtrlListView_GetItemCount($ListView1)-1
			If $Abbruchcode = 1 Then
				ExitLoop
			EndIf
			$aItem = _GUICtrlListView_GetItemTextArray($ListView1, $m)
			If $aItem[3] = "jpg" Or $aItem[3] = "bmp" Or $aItem[3] = "png" Then
				_GUICtrlListView_SetItemChecked($ListView1, $m, True)
				$BerichtMarkieren += 1
			EndIf
			$Fortschritt += (100/_GUICtrlListView_GetItemCount($ListView1))
			GUICtrlSetData($ProgressMarkieren, $Fortschritt)
			_Time("","")
		Next
	EndIf
	If GUICtrlRead($ChbBestimmte) = 1 Then
		GUICtrlSetData($ProgressMarkieren, 0)
		For $m = 0 To _GUICtrlListView_GetItemCount($ListView1)-1
			If $Abbruchcode = 1 Then
				ExitLoop
			EndIf
			$aItem = _GUICtrlListView_GetItemTextArray($ListView1, $m)
			If $aItem[3] = GUICtrlRead($inpMarkieren) Then
				_GUICtrlListView_SetItemChecked($ListView1, $m, True)
				$BerichtMarkieren += 1
			EndIf
			$Fortschritt += (100/_GUICtrlListView_GetItemCount($ListView1))
			GUICtrlSetData($ProgressMarkieren, $Fortschritt)
			_Time("","")
		Next
	EndIf
	$Fortschritt = 0
	GUICtrlSetData($ProgressMarkieren, 100)
	GUICtrlSetData($lblStatushFSTool, "Bereit" )
	$Abbruchcode = 0
	MsgBox(0,"","Anzahl markierte Elemente: " & $BerichtMarkieren)
	_State($Gui_Enable)
EndFunc


Func Kopie()
	AdlibRegister("_TimeSearch",10)
	$klText = ""
	Local $aItem, $sText
	$sText = ""
	$AnzahlFiles = _GUICtrlListView_GetItemCount($ListViewPlaylist)
	If $AnzahlFiles > 0 Then
		$Speicherort = FileSelectFolder("Choose a folder.", "")
		If Not @error Then
			$Prozent = 0

			GUICtrlSetData($lblStatushFSTool, "Kopieren")
			_State($Gui_Disable)
			DirCreate($Speicherort & "\FS-Tool")
			DirCreate($Speicherort & "\FS-Tool\Bilder")
			DirCreate($Speicherort & "\FS-Tool\Videos")
			DirCreate($Speicherort & "\FS-Tool\Musik")
			DirCreate($Speicherort & "\FS-Tool\Andere")
			For $n = 0 To $AnzahlFiles - 1
				If $AbbruchCode = 0 Then
					$aItem = _GUICtrlListView_GetItemTextArray($ListViewPlaylist, $n)
					$sText = $aItem[1] & $aItem[2] & "." & $aItem[3]
					If FileExists($aItem[1] & $aItem[2] & "." & $aItem[3]) Then
						If $aItem[3] = "jpg" Or $aItem[3] = "bmp" Or $aItem[3] = "png" Then
							FileCopy($sText ,$Speicherort & "\FS-Tool\Bilder\*.*")
						ElseIf $aItem[3] = "avi" Or $aItem[3] = "flv" Or $aItem[3] = "mp4" Or $aItem[3] = "mkv" Then
							FileCopy($sText ,$Speicherort & "\FS-Tool\Videos\*.*")
						ElseIf $aItem[3] = "mp3" Or $aItem[3] = "m4a" Or $aItem[3] = "aac" Or $aItem[3] = "wav" Or $aItem[3] = "wma" Then
							FileCopy($sText ,$Speicherort & "\FS-Tool\Musik\*.*")
						Else
							FileCopy($sText ,$Speicherort & "\FS-Tool\Andere\*.*")
						EndIf
					Else
						_Kopie_Loeschbericht($aItem[1] & $aItem[2] & "." & $aItem[3], "Kopieren")
					EndIf
					$NameAbbruch = $sText
					$sText = ""
				Else
					MsgBox(48,"Unterbruch","Der Kopiervorgang wurde unterbrochen!" & @CRLF & _
					"Zuletzt vollständig kopiertes File:" & @CRLF & _
					$NameAbbruch)
					ExitLoop
				EndIf
			Next
			_State($Gui_Enable)
			GUICtrlSetData($Progress1, 100)
			GUICtrlSetData($lblStatushFSTool, "Bereit")
			MsgBox(0,"Erfolg", "Kopieren erfolgreich abgeschlossen")
		EndIf
		If $klText <> "" Then
			MsgBox(0,"Error's beim Kopiervorgang", $klText)
		EndIf
	Else
		MsgBox(16,"Error","Die Zwischenablage ist Leer.")
	EndIf
EndFunc


Func Loeschen()
	AdlibRegister("_TimeSearch",10)
	$klText = ""
	Local $aItem, $sText
	$sText = ""
	$AnzahlFiles = _GUICtrlListView_GetItemCount($ListViewPlaylist)
	If $AnzahlFiles > 0 Then
		If MsgBox(36,"Bestätigen","Mit diesem Vorgang werden die Files unwiederruflich gelöscht. Möchten Sie den Vorgang fortsetzen?") = 6 Then
			_State($Gui_Disable)
			For $n = 0 To $AnzahlFiles - 1
				If $AbbruchCode = 0 Then
					$aItem = _GUICtrlListView_GetItemTextArray($ListViewPlaylist, $n)
					$sText = $aItem[1] & $aItem[2] & "." & $aItem[3]
					If FileExists($aItem[1] & $aItem[2] & "." & $aItem[3]) Then
						FileDelete($aItem[1] & $aItem[2] & "." & $aItem[3])
					Else
						_Kopie_Loeschbericht($aItem[1] & $aItem[2] & "." & $aItem[3], "Kopieren")
					EndIf
					$NameAbbruch = $sText
					$sText = ""
				Else
					MsgBox(48,"Unterbruch","Der Löschvorgang wurde unterbrochen!" & @CRLF & _
					"Zuletzt vollständig Gelöschtes File:" & @CRLF & _
					$NameAbbruch)
					ExitLoop
				EndIf
			Next
			_State($Gui_Enable)
			GUICtrlSetData($Progress1, 100)
			GUICtrlSetData($lblStatushFSTool, "Bereit")
			If $klText = "" Then
				MsgBox(0,"Erfolg", "Löschen erfolgreich abgeschlossen")
			Else
				MsgBox(0,"Error's beim Löschvorgang", $klText)
			EndIf
		Else
			MsgBox(0,"Abbruch", "Vorgang abgebrochen")
		EndIf
	Else
		MsgBox(16,"Error","Die Zwischenablage ist Leer.")
	EndIf
EndFunc


Func _Kopie_Loeschbericht($klText, $Vorgang)
	If $Vorgang = "Kopieren" Then
		$klText += @CRLF & $klText & " konnte nicht kopiert werden."
	ElseIf $Vorgang = "Löschen" Then
		$klText += @CRLF & $klText & " konnte nicht gelöscht werden."
	EndIf
EndFunc


Func _Beenden()
	If WinGetState($hMarkieren) <> 5 Or WinGetState($hSuche) <> 5 Or WinGetState($hSucheListe) <> 5 Or WinGetState($Playlist) <> 5 Then
		GUISetState(@SW_HIDE, $hMarkieren)
		GUISetState(@SW_HIDE, $hSuche)
		GUISetState(@SW_HIDE, $hSucheListe)
		GUISetState(@SW_HIDE, $Playlist)
	Else
		AdlibUnRegister("_Check")
		_GDIPlus_Shutdown()
		Exit
	EndIf
EndFunc


Func _Abbrechen()
	$Abbruchcode = 1
EndFunc


Func _TimeSearch()
	_Time("Search",0)
EndFunc

