找回密码
 加入
搜索
查看: 3634|回复: 9

[AU3基础] While 1 里有sleep就不能退出了吗

  [复制链接]
发表于 2010-7-26 20:28:57 | 显示全部楼层 |阅读模式
While 1
Sleep(5000)
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE  Then ExitLoop
Wend
$oIE=0              ; 清除内存
GUIDelete ()  

这样就不能退出了 去掉sleep就可以了
发表于 2010-7-26 20:37:39 | 显示全部楼层
Sleep(5000)=延时5秒。
每5秒检查一次$GUI_EVENT_CLOSE消息?
 楼主| 发表于 2010-7-26 20:53:14 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3> ;
#Region ### START Koda GUI section ###
$Form1 = GUICreate("窗体1",800, 600)
$oIE = ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($oIE,1,1, 800, 600)
While 1
$oIE.navigate("http://www.baidu.cn/")
Sleep(5000)
$oIE.navigate("http://www.google.com/")
Sleep(5000)
$oIE.navigate("http://www.hao123.com/")
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###
Sleep(5000)
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE  Then ExitLoop
Wend
$oIE=0              ; 清除内存
GUIDelete ()   

我的脚本是这样的 窗口关闭按钮没反映
 楼主| 发表于 2010-7-26 21:41:31 | 显示全部楼层
哪个高手帮检查下撒
发表于 2010-7-26 21:42:32 | 显示全部楼层
试试这个。
#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $url[3], $n = 1
$url[0] = "http://www.baidu.cn/"
$url[1] = "http://www.google.com/"
$url[2] = "http://www.hao123.com/"
#Region ### START Koda GUI section ###
$Form1 = GUICreate("窗体1", 800, 600)
$oIE = ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($oIE, 1, 1, 800, 600)
$oIE.navigate("http://www.baidu.cn/")
GUISetState(@SW_SHOW)

AdlibRegister("IE", 5000)
While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func IE()
        If $n = 3 Then $n = 0
        $oIE.navigate($url[$n])
        $n += 1
EndFunc   ;==>IE
$oIE = 0 ; 清除内存
GUIDelete()

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

发表于 2010-7-30 11:19:51 | 显示全部楼层
测试了下,5楼的代码应该可以解决楼主的问题。
 楼主| 发表于 2010-8-8 02:07:00 | 显示全部楼层
嗯 可以了 感谢大家热心帮助
发表于 2010-8-23 11:16:09 | 显示全部楼层
可能就是延迟造成的
发表于 2010-8-23 11:37:35 | 显示全部楼层
我已经很久不用超过sleep(10)的了,都用If TimerDiff($begin) > $befor * 1000 Then...
发表于 2013-4-13 17:17:16 | 显示全部楼层
这个可以。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-20 21:52 , Processed in 0.095982 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表