请帮我介绍如何创建列表,可能来自arrayList。输入框是文件夹的源,其所有png文件都在数组列表中,并在GU中显示。感谢
#include <GuiConstantsEx.au3>
#include <File.au3>
#include <Array.au3>
;GUI
GUICreate("Automation", 300, 500)
$sourceFolder = GUICtrlCreateInput ("Source Folder" , 10, 10,280, 20 )
$add = GUICtrlCreateButton("Add", 10, 35, 75, 20)
$mylist = GUICtrlCreateList("", 10, 60, 280, 300)
$sourceFolder = ControlGetText("Automation", "", "Edit1")
Local $FileList = _FileListToArray($sourceFolder, "*.png")
$msg = 0
While $msg
$msg = GUIGetMsg()
Select
Case $msg = $add
GUICtrlSetData($mylist,$FileList)
Exit
EndSelect
WEnd
If $sourceFolder > 1 Then
If @error = 1 Then
MsgBox(0, "", "No Folders Found.")
Exit
EndIf
If @error = 4 Then
MsgBox(0, "", "No Files Found.")
Exit
EndIf
$arrayFileList = _ArrayDisplay($FileList)
EndIf
; GUI MESSAGE LOOP
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
答案 0 :(得分:2)
您的代码中存在很多问题。
While $msg
,并且之前将$msg
设置为0
。 "Source Folder"
,而不是您想要的目录。就你想做什么而言:它只是返回数组的For ... Next循环。
#include <GuiConstantsEx.au3>
#include <File.au3>
#include <Array.au3>
;GUI
GUICreate("Automation", 300, 500)
$sourceFolder = GUICtrlCreateInput("Source Folder", 10, 10, 280, 20)
$add = GUICtrlCreateButton("Add", 10, 35, 75, 20)
$mylist = GUICtrlCreateList("", 10, 60, 280, 300)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $add
$sFolder = ControlGetText("Automation", "", "Edit1")
Local $FileList = _FileListToArray($sFolder, "*.*")
If @error = 1 Then
MsgBox(0, "", "No Folders Found.")
Exit
EndIf
If @error = 4 Then
MsgBox(0, "", "No Files Found.")
Exit
EndIf
For $i = 1 To $FileList[0]
GUICtrlSetData($mylist, $FileList[$i])
Next
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd