本帖最后由 cxm23 于 2021-3-10 11:22 编辑
想要循环获取文件夹下大小为0的文件,可是一进入循环后,就停止不了,程序也关不掉,不知有什么解决办法?#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 328, 91, 258, 185)
$Btn_start = GUICtrlCreateButton("循环下载", 128, 8, 89, 25)
$Btn_stop = GUICtrlCreateButton("停止", 224, 8, 89, 25)
GUICtrlSetState($Btn_stop, $GUI_DISABLE)
GUICtrlSetState($Btn_start, $GUI_ENABLE)
GUISetState(@SW_SHOW)
Global $ONOFF = 1
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Btn_start
$ONOFF = 1
GUICtrlSetState($Btn_start, $GUI_DISABLE)
GUICtrlSetState($Btn_stop, $GUI_ENABLE)
While $ONOFF
download()
Sleep(30000)
WEnd
Case $Btn_stop
$ONOFF = 0
GUICtrlSetState($Btn_stop, $GUI_DISABLE)
GUICtrlSetState($Btn_start, $GUI_ENABLE)
EndSwitch
WEnd
Func download()
$path = "D:\Video"
Local $file = _FileListToArray($path, "*.mp4", 1)
If @error Then
Return
EndIf
Local $i
Local $file0[1]
Local $n = 0
For $i = 1 To UBound($file) - 1
$size1 = FileGetSize($path & "" & $file[$i])
If $size1= 0 Then
$n += 1
redim $file0[$n]
$file0[$n-1] = $file[$i]
EndIf
Next
EndFunc
|