找回密码
 加入
搜索
查看: 1152|回复: 5

ImgGetCollection怎么遍历模拟点击

[复制链接]
发表于 2009-5-12 14:02:47 | 显示全部楼层 |阅读模式
本帖最后由 jhkdqaa 于 2009-5-13 11:59 编辑

关于一个php的网页。新手上路,大侠们帮忙看看
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

$Form1 = GUICreate("每日自动刷新",700,480)
$Group1 = GUICtrlCreateGroup("", 8, 8, 684, 400)
$oIE = _IECreateEmbedded ()
$GUIActiveX = GUICtrlCreateObj($oIE,16, 24, 668, 374)
$Edit = GUICtrlCreateEdit("", 8, 420, 500,50)
GUICtrlSetBkColor(-1, 0xFFFFE1)
GUICtrlSetColor(-1, 0x008000)
$Button1 = GUICtrlCreateButton("首 页", 516, 420, 84, 50)
$Button2 = GUICtrlCreateButton("刷 新", 608, 420, 84, 50)
GUISetState(@SW_SHOW)
$oIE.navigate("http://www.asianproducts.com/")
GUICtrlSetData($Edit,"请自行设置用户名和密码登陆")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $oIE.navigate("http://www.asianproducts.com/")           
        Case $Button2
            $UserName = _IEGetObjById ($oIE, "client_login_name")
             If IsObj($UserName) Then $UserName.value = "留着以后读数据库"
            $PassWord = _IEGetObjById ($oIE, "client_login_password")
             If IsObj($PassWord) Then $PassWord.value = "留着以后读数据库"
             $submit = _IEGetObjById ($oIE, "button")
             If IsObj($submit) Then $submit.click
            sleep(2000)
            GUICtrlSetData($Edit,"请稍后,正在操作...")
             _IELoadWait($oIE)
            GUICtrlSetData($Edit,"已登陆")
                        $oIE.navigate("http://www.asianproducts.com/member.php")
                        _IELoadWait($oIE)
                        _IELinkClickByText($oIE,"My online products")
                        _IELoadWait($oIE)
                        _IEImgClick($oIE,"http://www.asianproducts.com/clientAdmin/images/big_icon3_smaller.gif","src")
                        _IELoadWait($oIE)
                        _IEImgClick($oIE,"http://www.asianproducts.com/clientAdmin/images/save_data1.gif","src")
                EndSwitch
WEnd
问题就是这个网页有N个长的一样的图片链接,怎样通过_IEImgGetCollection逐个点击?只需要针对第一个图片链接就可以了。坐等高手帮忙
 楼主| 发表于 2009-5-12 14:11:15 | 显示全部楼层
是不是
                        $oImgs = _IEImgGetCollection ($oIE)
                        For $oImg In $oImgs
                        If StringInStr($oImg.src,"http://www.asianproducts.com/clientAdmin/images/big_icon3_smaller.gif") = 0 Then
then后面的click怎么写?这样就可以遍历么?
发表于 2009-5-12 22:31:34 | 显示全部楼层
是不是
                        $oImgs = _IEImgGetCollection ($oIE)
                        For $oImg In $oImgs
                        If StringInStr($oImg.src,"http://www.asianproducts.com/clientAdmin/images/big_icon3_smaller.gif") = 0 Then
then后面的click怎么写?这样就可以遍历么?
 楼主| 发表于 2009-5-13 09:04:25 | 显示全部楼层
你干嘛复制我的话。。。。。这是灌水新方法吗
 楼主| 发表于 2009-5-13 11:08:17 | 显示全部楼层
本帖最后由 jhkdqaa 于 2009-5-13 11:59 编辑

自己解决了一部分,发出来新手交流下。
$oimgs = _IEImgGetCollection($oIE)
$iNumimg = @extended
dim $imglist[$iNumimg]
dim $i = 0
for $i = 0 to @extended
        $imglist[$i] = _IEImgGetCollection($oIE, $i)
        oimgclick = $imglist[$i]
        if $oimgclick.src = "http://www.asianproducts.com/clientAdmin/images/big_icon3_smaller.gif" then
        _IEAction($oimgclick, "click")
        _IELoadWait($oIE)
        _IEImgClick($oIE, "http://www.asianproducts.com/clientAdmin/images/save_data1.gif", "src")
        _IELoadWait($oIE)
        _IELinkClickByText($oIE, "My online products")
        _IELoadWait($oIE)
        EndIf
next
已经可以实现遍历,但是在遍历完成以后,i=10<@extended,会继续循环,错误退出。但是把@extended改成数字就会出错。高手教导下怎么停止循环?是 if $i = 9 then end loop 么?
大概是这个意思,教程里没有提到怎么终止循环,帮助里搜索loop为空。坐等高手上文教导
 楼主| 发表于 2009-5-13 11:58:16 | 显示全部楼层
自己搞定:for $i = 0 to @extended
改成 for $i = 0 to (@extended -1)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-8 04:36 , Processed in 0.072750 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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