找回密码
 加入
搜索
查看: 4734|回复: 13

[AU3基础] 占cpu历害怎么改善一下(已解决)

 火.. [复制链接]
发表于 2011-10-16 17:48:46 | 显示全部楼层 |阅读模式
本帖最后由 xymc 于 2011-10-23 14:06 编辑

While 1
Sleep(500)
Local $Inbaidu=False
$oShell=ObjCreate('Shell.Application')
For $oWindow In $oShell.Windows
        If StringInStr($oWindow.LocationURL,'baidu.com') Then
                $Inbaidu=True
                ExitLoop
        EndIf
Next

If $Inbaidu=True Then
        ExitLoop
EndIf

    WEnd

这样可以吗?Sleep(500),延迟这个值设多大合适点又不会失败???

还有以下这个,哪一个会好点???
While 1
Sleep(1000)
$oShell = ObjCreate('shell.application')
$oShellWindows = $oShell.windows
For $Window In $oShellWindows
If StringRight($Window.FullName, 12) = 'iexplore.exe' Then                        
If $Window.locationurl='http://www.baidu.com/' Or $Window.locationurl='http://www.baidu.com' Then Exit

EndIf
Next
WEnd
以上2个代码都会偶尔出现这个错误。

评分

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

查看全部评分

发表于 2011-10-16 18:47:23 | 显示全部楼层
没明白你代码的意思!
#include <IE.au3>
$oIE = _IECreate ("www.baidu.com", 1)
_IELoadWait ($oIE)
MsgBox(0, '', '加载完成')
发表于 2011-10-16 18:52:54 | 显示全部楼层
加个sleep(500)
 楼主| 发表于 2011-10-16 19:41:17 | 显示全部楼层
本帖最后由 xymc 于 2011-10-16 19:42 编辑

回复 2# 水木子


    我想检测到百度后就退出,明白了吗?
等待百度网页窗口的出现,如果出现了就退出
发表于 2011-10-16 20:24:24 | 显示全部楼层
用3楼的方法试试
 楼主| 发表于 2011-10-16 23:57:27 | 显示全部楼层
回复 3# kevinch

在哪里加延迟?
发表于 2011-10-17 00:01:32 | 显示全部楼层
回复 6# xymc


    for 循环里加,不要加到if里面去了
 楼主| 发表于 2011-10-17 00:33:40 | 显示全部楼层
本帖最后由 xymc 于 2011-10-17 00:43 编辑

回复 7# xwt620


    While 1
Sleep(500)
Local $Inbaidu=False
$oShell=ObjCreate('Shell.Application')
For $oWindow In $oShell.Windows
        If StringInStr($oWindow.LocationURL,'baidu.com') Then
                $Inbaidu=True
                ExitLoop
        EndIf
Next

If $Inbaidu=True Then
        ExitLoop
EndIf

    WEnd

这样可以吗?Sleep(500),延迟这个值设多大合适点又不会失败???

还有以下这个,哪一个会好点???
While 1
Sleep(1000)
$oShell = ObjCreate('shell.application')
$oShellWindows = $oShell.windows
For $Window In $oShellWindows
If StringRight($Window.FullName, 12) = 'iexplore.exe' Then                        
If $Window.locationurl='http://www.baidu.com/' Or $Window.locationurl='http://www.baidu.com' Then Exit

EndIf
Next
WEnd
发表于 2011-10-17 00:43:52 | 显示全部楼层
回复 8# xymc


    一般10毫秒都可以解决CPU暂用的问题,除非是机器配置比较差才用100毫秒以上的延时
如果延时太久也容易造成机器反应迟钝的问题。
发表于 2011-10-17 08:23:29 | 显示全部楼层
回复 6# xymc

加在Wend前面
发表于 2011-10-17 13:03:39 | 显示全部楼层
回复 8# xymc
sleep(100)就差不多了
发表于 2011-10-17 18:15:20 | 显示全部楼层
你这样的循环 肯定占用很高了
 楼主| 发表于 2011-10-18 15:13:31 | 显示全部楼层
回复 10# kevinch


    加在Wend前面跟我的加在一开始有什么区别?
发表于 2012-4-20 23:25:14 | 显示全部楼层
某些确实暂用高啊
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-30 13:25 , Processed in 0.078272 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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