kann man das skript kürzen?

  • Spoiler anzeigen
    [autoit]

    If $Filelist[0]=0 Then
    MsgBox(0,"Fehler","Der angegebene Ordner enthält keine dateien.")
    Else
    Case $Filelist[0]=2
    $Name1= $Filelist[1]
    $Name2= ""
    $Name3= ""
    $Name4= ""
    $Name5= ""
    $Name6= ""
    $Name7= ""
    $Name8= ""
    $Name9= ""
    $Name10= ""
    $Name11= ""
    $Name12=""
    Case $Filelist[0]=2
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= ""
    $Name4= ""
    $Name5= ""
    $Name6= ""
    $Name7= ""
    $Name8= ""
    $Name9= ""
    $Name10= ""
    $Name11= ""
    $Name12=""
    Case $Filelist[0]=3
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= $Filelist[3]
    $Name4= ""
    $Name5= ""
    $Name6= ""
    $Name7= ""
    $Name8= ""
    $Name9= ""
    $Name10= ""
    $Name11= ""
    $Name12=""
    Case $Filelist[0]=4
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= $Filelist[3]
    $Name4= $Filelist[4]
    $Name5= ""
    $Name6= ""
    $Name7= ""
    $Name8= ""
    $Name9= ""
    $Name10= ""
    $Name11= ""
    $Name12=""
    Case $Filelist[0]=5
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= $Filelist[3]
    $Name4= $Filelist[4]
    $Name5= $Filelist[5]
    $Name6= ""
    $Name7= ""
    $Name8= ""
    $Name9= ""
    $Name10= ""
    $Name11= ""
    $Name12=""
    Case $Filelist[0]=6
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= $Filelist[3]
    $Name4= $Filelist[4]
    $Name5= $Filelist[5]
    $Name6= $Filelist[6]
    $Name7= ""
    $Name8= ""
    $Name9= ""
    $Name10= ""
    $Name11= ""
    $Name12=""
    Case $Filelist[0]=7
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= $Filelist[3]
    $Name4= $Filelist[4]
    $Name5= $Filelist[5]
    $Name6= $Filelist[6]
    $Name7= ""
    $Name8= ""
    $Name9= ""
    $Name10= ""
    $Name11= ""
    $Name12=""
    Case $Filelist[0]=8
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= $Filelist[3]
    $Name4= $Filelist[4]
    $Name5= $Filelist[5]
    $Name6= $Filelist[6]
    $Name7= $Filelist[7]
    $Name8= $Filelist[8]
    $Name9= ""
    $Name10=""
    $Name11=""
    $Name12=""
    Case $Filelist[0]=9
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= $Filelist[3]
    $Name4= $Filelist[4]
    $Name5= $Filelist[5]
    $Name6= $Filelist[6]
    $Name7= $Filelist[7]
    $Name8= $Filelist[8]
    $Name9= $Filelist[9]
    $Name10= ""
    $Name11= ""
    $Name12=""
    Select
    Case $Filelist[0]=10
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= $Filelist[3]
    $Name4= $Filelist[4]
    $Name5= $Filelist[5]
    $Name6= $Filelist[6]
    $Name7= $Filelist[7]
    $Name8= $Filelist[8]
    $Name9= $Filelist[9]
    $Name10= $Filelist[10]
    $Name11=""
    $Name12=""

    Case $Filelist[0]=11
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= $Filelist[3]
    $Name4= $Filelist[4]
    $Name5= $Filelist[5]
    $Name6= $Filelist[6]
    $Name7= $Filelist[7]
    $Name8= $Filelist[8]
    $Name9= $Filelist[9]
    $Name10= $Filelist[10]
    $Name11= $Filelist[11]
    $Name12=""

    Case $Filelist[0]=12
    $Name1= $Filelist[1]
    $Name2= $Filelist[2]
    $Name3= $Filelist[3]
    $Name4= $Filelist[4]
    $Name5= $Filelist[5]
    $Name6= $Filelist[6]
    $Name7= $Filelist[7]
    $Name8= $Filelist[8]
    $Name9= $Filelist[9]
    $Name10= $Filelist[10]
    $Name11= $Filelist[11]
    $Name12= $Filelist[12]
    EndSelect

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

    EndIf

    [/autoit]


    Ich habs jetzt ca. 2.5 stunden durchprobiert,und komm einfach nicht drauf wie ich das teil hier kürzen kann ohne eine arrayerror zu bekommen.
    Is bis jetzt auch das erste mal das ich mich mit arrays auseinandersetzte.....
    Ich möchte die ordner,die sich in einem verzeichniss befinden graphisch anzeigen,und dass sol natürlich universell anwendbar sein und nicht nur bei 12 bzw weniger ^^.

  • So,habs es jetzt geschafft ein verzeichnis graphisch darzustellen.
    Im moment mehr schlecht als recht, aber eagal ^^.
    Werds jetzt noch weiter ausbauen, freue mich aber über tipps und anregungen.
    edit: Werde es demnächst so umstellen, das ich die endungen erkenne und dann eine fallunterscheidung macht.

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <File.au3>

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

    $Pfad=@DesktopDir
    $FileList=_FileListToArray($Pfad)
    If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
    EndIf

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

    If $Filelist[0]=0 Then
    MsgBox(0,"Fehler","Der angegebene Ordner enthält keine dateien.")
    EndIf

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

    For $i = 1 to $Filelist[0]
    Assign('Name'&$i, $Filelist[$i])
    Next

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 874, 652, 191, 132)
    GUISetCursor (0)
    $Button1 = GUICtrlCreateButton("", 0, 0, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name1"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name1"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button2 = GUICtrlCreateButton("", 0, 40, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name2"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name2"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button3 = GUICtrlCreateButton("", 0, 80, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name3"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name3"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button4 = GUICtrlCreateButton("", 0, 120, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name4"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name4"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button5 = GUICtrlCreateButton("", 0, 160, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name5"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name5"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button6 = GUICtrlCreateButton("", 0, 200, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name6"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name6"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button7 = GUICtrlCreateButton("", 0, 240, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name7"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name7"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button8 = GUICtrlCreateButton("", 0, 280, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name8"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name8"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button9 = GUICtrlCreateButton("", 0, 320, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name9"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name9"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button10 = GUICtrlCreateButton("", 0, 360, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name10"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name10"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button11 = GUICtrlCreateButton("", 0, 400, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name11"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name11"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Button12 = GUICtrlCreateButton("", 0, 440, 36, 36, $BS_ICON)
    If StringInStr(Eval("Name12"), ".")=0 Then
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 4)
    Else
    GUICtrlSetImage(-1, $Pfad&"/"&Eval("Name12"), 0)
    EndIf
    GUICtrlSetCursor (-1, 0)
    $Next = GUICtrlCreateButton("Nächste Seite", 592, 496, 121, 33, 0)
    GUICtrlSetCursor (-1, 0)
    $Label1 = GUICtrlCreateLabel(Eval("Name1"), 40, 0, 829, 36)
    $Label2 = GUICtrlCreateLabel(Eval("Name2"), 40, 40, 829, 36)
    $Label3 = GUICtrlCreateLabel(Eval("Name3"), 40, 80, 829, 36)
    $Label4 = GUICtrlCreateLabel(Eval("Name4"), 40, 120, 829, 36)

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

    $Label5 = GUICtrlCreateLabel(Eval("Name5"), 40, 160, 829, 36)
    $Label6 = GUICtrlCreateLabel(Eval("Name6"), 40, 200, 829, 36)
    $Label7 = GUICtrlCreateLabel(Eval("Name7"), 40, 240, 829, 36)
    $Label8 = GUICtrlCreateLabel(Eval("Name8"), 40, 280, 829, 36)
    $Label9 = GUICtrlCreateLabel(Eval("Name9"), 40, 320, 829, 36)
    $Label10 = GUICtrlCreateLabel(Eval("Name10"), 40, 360, 829, 36)
    $Label11 = GUICtrlCreateLabel(Eval("Name11"), 40, 400, 829, 36)
    $Label12 = GUICtrlCreateLabel(Eval("Name12"), 40, 440, 829, 36)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    ExitLoop

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

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit]
    • Offizieller Beitrag

    Hallo

    Wenn kürzen dann aber richtig :D :

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <File.au3>

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

    $Pfad = @DesktopDir
    $FileList = _FileListToArray($Pfad)
    If @error = 1 Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
    EndIf

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

    If $FileList[0] = 0 Then
    MsgBox(0, "Fehler", "Der angegebene Ordner enthält keine dateien.")
    EndIf

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

    For $i = 1 To $FileList[0]
    Assign('Name' & $i, $FileList[$i])
    Next

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

    $Form1 = GUICreate("Form1", 874, 652, 191, 132)
    GUISetCursor(0)

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

    $y = 0
    For $i = 1 To 12
    Assign("Button" & $i, GUICtrlCreateButton("", 0, $y, 36, 36, $BS_ICON))
    If StringRight(Eval("Name" & $i),4) = ".lnk" Then
    $aIcon = FileGetShortcut ($Pfad & "\" & Eval("Name" & $i))
    GUICtrlSetImage(-1, $aIcon[4],$aIcon[5])
    Else
    GUICtrlSetImage(-1, "C:\WINDOWS\system32\SHELL32.dll", 3)
    EndIf
    GUICtrlSetCursor(-1, 0)
    Assign("Label" & $i, GUICtrlCreateLabel(Eval("Name" & $i), 40, $y, 829, 36))
    $y += 40
    Next
    $Next = GUICtrlCreateButton("Nächste Seite", 592, 496, 121, 33, 0)
    GUICtrlSetCursor(-1, 0)

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

    GUISetState()

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    ExitLoop

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

    EndSwitch
    WEnd

    [/autoit]

    Nächstes µIt kann kommen ;)

    Mfg Spider