找回密码
 加入
搜索
查看: 3946|回复: 4

[IE类操作] ie操作的一个小错误,不知道如何避免

[复制链接]
发表于 2013-6-20 09:02:00 | 显示全部楼层 |阅读模式
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GDIPlusEx.au3>
#include <String.au3>
#Include <Date.au3>
#include <Winhttp_GetRespond.au3>
#include <ie.au3>


Opt("WinTitleMatchMode", 2)
While 1
ToolTip(ControlGetText ("Windows Internet Explorer", "", 'Edit1'),5,5)
if StringInStr(ControlGetText ("Windows Internet Explorer", "", 'Edit1'),"http://t.qq.com/") Then
   $wb_url=ControlGetText ("Windows Internet Explorer", "", 'Edit1')
   ExitLoop
EndIf
Sleep(100)
WEnd

   Local $i,$aArray,$oSpans,$oSpan

                        $IE = _IECreateEmbedded ()
                        $sub2=GUICreate("wb",  402, 386,5,5)
                        GUICtrlCreateObj($IE, 0, 0, 402,386) 
                        ;GUISetState(@SW_hide)
                        GUISetState(@SW_show)
                                        _IENavigate ($IE, $wb_url)
                                                if IsObj($ie) Then                                           
                                                                 $oSpans =  _IETagNameGetCollection($IE, "U")
                                                                 if IsObj($oSpans) Then
                                                                          For $oSpan In $oSpans
                                                                                  if IsObj($oSpan) Then        

                                                                                                   If StringInStr($oSpan.outerhtml, "首页") Then
                                                                                                                 Sleep(3000)
                                                                                                                 MsgBox(0,"2","")
                                                                                                                 For $x=40 To 310 Step 40
                                                                                                                        ControlClick ("wb","","","left",1,$x,237)
                                                                                                                 Next                                                                                  
                                                                                                                 $oSpan.click
                                                                                                                 Sleep(1000)
                                                                                                                 $oText = _IEGetObjById ($ie, "msgTxt")
                                                                                                                 _IEFormElementSetValue ($oText, "你好!")
                                                                                                                 Sleep(2000)
                                                                                                                  $oSpans =  _IETagNameGetCollection($IE, "INPUT")
                                                                                                                 if IsObj($oSpans) Then
                                                                                                                          For $oSpan In $oSpans
                                                                                                                                  if IsObj($oSpan) Then        
                                                                                                                                                   If StringInStr($oSpan.title, "广播") Then
                                                                                                                                                        $oSpan.click  
                                                                                                                                                   EndIf
                                                                                                                                  EndIf
                                                                                                                          Next
                                                                                                                 EndIf
;ExitLoop 这里不加EXITLOOP让循环一直下去就会出错

                                                                                                   EndIf
                                                                                  EndIf
                                                                          Next
                                                                   EndIf
                                                                EndIf                   
While 1
Sleep(100)
WEnd
为什么那个EXITLOOP不去掉的话,执行代码就会出现:
The requested action with this object has failed.:
If StringInStr($oSpan.outerhtml, "??") Then
If StringInStr($oSpan.outerhtml^ ERROR

这种错误提示呀?如何才能不加EXITLOOP,循环到结束也不会出错退出呢?
 楼主| 发表于 2013-6-20 09:04:13 | 显示全部楼层
不好意思,不知道这代码块如何整体向左移的快捷键是什么,弄得上面的代码排序乱七八糟,大家将就着看下吧
 楼主| 发表于 2013-6-20 11:22:52 | 显示全部楼层
今天人好少哦,全都上班去了么
发表于 2013-6-20 12:12:24 | 显示全部楼层
天太热了 理解能力又差 没心情细看 如果不EXITLOOP就会出错 那说明是循环上写法有问题 如果是有时要出错 有时不出错  很可能是 $obj.xxx上的问题 像IE这种最好还是 将$oHTTP.responsetext 换成 _IEBodyReadText好一点 前面种出错了脚本就报错了 后面种出错了只影响返回的结果 不影响脚本的运行 不知道为什么  求高人解释。
发表于 2013-6-20 12:13:06 | 显示全部楼层
回复 2# z761003


    ctrl+t
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-4 09:21 , Processed in 0.078610 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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