注册 登录
编程论坛 VB6论坛

用WebBrowser1登录QQ的问题

ease1000 发布于 2013-05-14 12:54, 2416 次点击
Private Sub Command1_Click()
    WebBrowser1.Navigate2 "http://ui.ptlogin2.
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, Url As Variant)
    'On Error Resume Next
    If InStr(Url, "ui.ptlogin2.) <> 0 Then '登录页面
        pDisp.Document.getElementById("u").Value = "392354601"      '账号
        pDisp.Document.getElementById("p").Value = "a123456"        '密码
        
        pDisp.Document.getElementById("p").onchange
        pDisp.Document.getElementById("p").Click


        'pDisp.Document.getElementById("verifycode").Value = "xmsz" '验证码
        'pDisp.Document.getElementById("login_button").Click         '登录
    End If
End Sub
'源码如下
Private Sub Command1_Click()
    WebBrowser1.Navigate2 "http://ui.ptlogin2.
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, Url As Variant)
    On Error Resume Next
    If InStr(Url, "ui.ptlogin2.) <> 0 Then '登录页面
        pDisp.Document.getElementById("u").Value = "392354601"      '账号

        pDisp.Document.getElementById("p").Value = "a123456"        '密码
        pDisp.Document.getElementById("p").Click                    '密码框需要手动点击一下,这句没有效果?

        'pDisp.Document.getElementById("verifycode").Value = "xmsz" '验证码

        'pDisp.Document.getElementById("login_button").Click         '登录
    End If
End Sub

直接按登录键不能正确登录 , 会出现验证码的提示框
如果手动点击密码框一下 , 再按登录键则可正常登录
求高手指点
2 回复
#2
a8141532013-05-18 05:49
回复 楼主 ease1000
pDisp.document.getElementById("login_button").Click  '登录
#3
a8141532013-05-18 05:56
Sub Command1_Click()
    On Error Resume Next
    With CreateObject("internetexplorer.application")
        .Visible = True
        .Navigate "https://ui.ptlogin2.
        Do Until .ReadyState = 4
            DoEvents
        Loop
        .document.getElementById("u").Value = "392354601"      '账号
        .document.getElementById("p").Value = "a123456"        '密码
        t1 = Timer
        Do Until Timer > t1 + 4                                '等待4秒
            DoEvents
        Loop
        .document.getElementById("login_button").Click         '登录
    End With
End Sub


[ 本帖最后由 a814153 于 2013-5-18 07:35 编辑 ]
1