1,502
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
'取验证码+自动填表例子
'
'窗体上添加一个WebBrowser1,Picture1,Timer1
'
'BY 嗷嗷叫的老马
'http://www.m5home.com
Dim oHTML As Object
Private Sub Form_Load()
Timer1.Enabled = False
WebBrowser1.Navigate "http://www.aocdisplay.com.cn/activity/detail.asp?id=39268"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If URL = "http://www.aocdisplay.com.cn/activity/vote.asp?id=39268&sid=a744f808e9c4759586da57f92bfeacbd&" Then
Set oHTML = pDisp
Timer1.Interval = 1000 '等小窗口验证码刷新后再提取
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
Dim oTmp As Object, CR As Object
Set oTmp = oHTML.Document.getElementById("Uid") '用户名
oTmp.Value = "asdfasdf"
Set oTmp = oHTML.Document.getElementById("Pwd") '密码
oTmp.Value = "asdfasdf"
Set oTmp = oHTML.Document.getElementById("Vcd") '验证码
oTmp.Value = "asdfasdf"
Set oTmp = oHTML.Document.getElementById("validatorImage") '得到验证码
Set CR = oHTML.Document.body.createControlRange() '设置选区
CR.Add oTmp '添加验证码图片对象到选区
CR.execCommand ("Copy") '复制
Set Picture1.Picture = Clipboard.GetData() '粘贴过去
End Sub