huguanglai 发表于 2010-9-13 21:03:33

ie.au3 提交不了

本帖最后由 huguanglai 于 2010-9-13 21:15 编辑

下面是我的写的代码,但是就是提交不了.
#include <IE.au3>
$oIE = _IECreate ("mail.163.com",0,1,1,0)

$ofrm=_IEFormGetObjByName($oIE,"login163")
$oquest1=_IEFormElementGetObjByName($ofrm,"username")
_IEFormElementSetValue($oquest1,"11111")
$oquest2=_IEFormElementGetObjByName($ofrm,"password")
_IEFormElementSetValue($oquest2,"11111")
$oQuery = _IEFormElementGetObjByName ($ofrm, "selType")
_IEFormElementOptionSelect ($oQuery , 1, 1, "byIndex")

$osubmit = _IEFormElementGetObjByName ($ofrm, "登 录")
_IEFormSubmit($osubmit)



这个是网页代码:<button class="btn btn-login" onMouseOver="this.className+=' btn-login-hover'" onMouseDown="this.className+=' btn-login-active'" onMouseOut="this.className='btn btn-login'" onMouseUp="this.className='btn btn-login'" tabindex="6" type="submit" onClick="if(window.location.href.indexOf('#return') == -1){setCookie('ntes_mail_firstpage','normal');}saveLoginType();">登 录</button>


那位高手过来解释下

baikaifang 发表于 2010-9-15 12:43:03

$osubmit = _IEFormElementGetObjByName ($ofrm, "登 录");错误了,该语句无法获取按钮对象。
_IEFormSubmit($osubmit);这个函数用法也错了,参数应该是表单对象。

下面是改进后的代码:#include <IE.au3>

$oIE = _IECreate ("mail.163.com",0,1,1,0)
$ofrm=_IEFormGetObjByName($oIE,"login163")
$oquest1=_IEFormElementGetObjByName($ofrm,"username")
_IEFormElementSetValue($oquest1,"11111")
$oquest2=_IEFormElementGetObjByName($ofrm,"password")
_IEFormElementSetValue($oquest2,"11111")
$oQuery = _IEFormElementGetObjByName ($ofrm, "selType")
_IEFormElementOptionSelect ($oQuery , 1, 1, "byIndex")

Dim $oButtons, $oLogin

$oButtons = _IETagNameGetCollection($oIE, 'button', -1)
If IsObj($oButtons) Then
        For $oLogin In $oButtons
                If StringInStr($oLogin.className(), 'btn-login') And StringInStr($oLogin.innerText(), '登 录') Then
                        $oLogin.click()
                        ExitLoop
                EndIf
        Next
Else
        MsgBox(64, '提示', '登陆失败!')
EndIf

liufenglg 发表于 2010-9-15 16:41:38

$osubmit = _IEFormElementGetObjByName ($ofrm, "登 录");错误了,该语句无法获取按钮对象。
_IEFormS ...
baikaifang 发表于 2010-9-15 12:43 http://www.autoitx.com/images/common/back.gif


    又学习了
页: [1]
查看完整版本: ie.au3 提交不了