GUI占用CPU100%的问题?
#include <ButtonConstants.au3>#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 315, 171, 215, 212)
$Button1 = GUICtrlCreateButton("开始", 192, 120, 49, 33)
$Button2 = GUICtrlCreateButton("退出", 255, 119, 49, 33)
$Label1 = GUICtrlCreateLabel("请选择核心目录:", 22, 34, 100, 25)
$Input1 = GUICtrlCreateInput("", 24, 64, 225, 21)
$Button3 = GUICtrlCreateButton("浏览", 264, 64, 33, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $var, $ok
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_shanchu()
Case $Button2
Exit
Case $Button3
GUICtrlSetState($Button3, $GUI_DISABLE)
$var = FileSelectFolder("请选择目录:", "")
GUICtrlSetData($Input1, $var, GUICtrlRead($Input1))
$ok = 1
If FileExists($var)=0 Then
Else
GUICtrlSetData($Input1,$var)
EndIf
GUICtrlSetState($Button3, $GUI_ENABLE)
GUICtrlSetBkColor($Input1, 0xFFFAF0)
EndSwitch
WEnd
Func _shanchu()
GUICtrlSetState($Button1, $GUI_DISABLE)
$var &= "\log"
$lujing = $var
MsgBox(0,"",$lujing)
While 1
FileDelete($lujing)
Sleep(5000)
WEnd
EndFunc谁能帮我看看是怎么回事,只要我一点开始CPU使用就狂飙到100%,而且还不能退出,研究很久了实在是找不到原因了。 没有人知道是哪里出现问题了吗?{:face (319):} 一点开始CPU使用就狂飙到100%---我这里测试正常
而且还不能退出---Func _shanchu()那一段代码用一个while已经进入死循环了,当然无法响应GUI退出消息了 那就没办法退出了吗? 楼主应该再多看看帮助,其实代码并不难。
多嘴勿怪。#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 315, 171, 215, 212)
$Button1 = GUICtrlCreateButton("开始", 192, 120, 49, 33)
$Button2 = GUICtrlCreateButton("退出", 255, 119, 49, 33)
$Label1 = GUICtrlCreateLabel("请选择核心目录:", 22, 34, 100, 25)
$Input1 = GUICtrlCreateInput("", 24, 64, 225, 21)
$Button3 = GUICtrlCreateButton("浏览", 264, 64, 33, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $var, $ok
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_shanchu()
Case $Button2
Exit
Case $Button3
GUICtrlSetState($Button3, $GUI_DISABLE)
$var = FileSelectFolder("请选择目录:", "")
If @error Then
$var = GUICtrlRead($Input1)
Else
GUICtrlSetData($Input1, $var)
EndIf
GUICtrlSetState($Button3, $GUI_ENABLE)
GUICtrlSetBkColor($Input1, 0xFFFAF0)
EndSwitch
WEnd
Func _shanchu()
GUICtrlSetState($Button1, $GUI_DISABLE)
$lujing = $var & "\log\"
If FileExists($lujing) Then
$search = FileFindFirstFile($lujing&"*.*")
If $search = -1 Then
MsgBox(0, "错误", "没有文件/目录 匹配搜索")
Exit
EndIf
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
MsgBox(4096, "文件:", $lujing&$file);如果删除文件这行改为Filedelete($lujing&$file)
WEnd
FileClose($search)
Else
MsgBox(0,"警告","未找到LOG文件夹")
EndIf
EndFunc ;==>_shanchu
谢谢你,但是我还有个问题没解决,就是我想循环执行删除脚本,我一加上时间程序就退不出来了,能给我一个思路吗? 回复 6# 93779252
见第55行注释 回复 6# 93779252
while 1
sleep(500)
页:
[1]