本帖最后由 vivier001 于 2009-11-25 16:25 编辑
长时间要运行动作并不就是sleep(),sleep已经休眠了~
最好有个长时间运行的实例,再看怎样处理比较好~
afan 发表于 2009-11-25 14:21
好像这样就行了,首先采用的是opt ("GUIOnEventMode",0)模式,
然后点击按钮后设置opt ("GUIOnEventMode",1)然后退出while之前
加上opt ("GUIOnEventMode",0)#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 0)
$mainwindow = GUICreate("您好,世界", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
$okbutton = GUICtrlCreateButton("确定", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")
GUISetState(@SW_SHOW)
While 1
Sleep(1000)
WEnd
Func OKButton()
Opt("GUIOnEventMode", 1)
While 1
If GUIGetMsg() = -3 Then CLOSEClicked()
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("post",".......",false)
$oHTTP.setRequestHeader("Cache-Control", "no-cache")
$oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
$oHTTP.Send("")
If ... Then
opt ("GUIOnEventMode",0)
ExitLoop
EndIf
$oHTTP.Open("post",".......",false)
$oHTTP.setRequestHeader("Cache-Control", "no-cache")
$oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
$oHTTP.Send("")
If ... Then
opt ("GUIOnEventMode",0)
ExitLoop
EndIf
.........
WEnd
EndFunc ;==>OKButton
Func CLOSEClicked()
Exit
EndFunc ;==>CLOSEClicked
|