VBS监控带计时器的网页 并完成自动计时

原始网页

 

 

运行VBS以后的效果.

 

 

Dim ie, strVal, intKey1, intKey2, bChk
Set ie = CreateObject("internetexplorer.application")
ie.Visible = True


''登录URL
ie.navigate "http://xxxxxxxxxxxx.com.cn/Login/Login.aspx"
If Not ie Is Nothing Then
    Do While ie.readystate <> 4
      If ie Is Nothing Then Exit Do
    Loop
End If

 

'On Error Resume Next

If Not ie Is Nothing Then
  '自动登录,由于有图形检验码不能自动完成,
    If ie.document.location = "http://xxxxxxxxxxxx.com.cn/Login/Login.aspx" Then
        ie.document.All("txtUserName").Value = "username"
        ie.document.All("txtPassWord").Value = "password" '密码
        ie.document.All("txtCode").Focus  '检验码
    End If
End If

 

If Not ie Is Nothing Then
  '等待打开带计时器的URL
    Do While Left(ie.document.location, 61) <> "http:///xxxxx.xxxxxx.com.cn/xxxxxxxxxxx/xxxxxfrm.aspx?BookID="
        If Left(ie.document.location, 61) = "http:///xxxxx.xxxxxx.com.cn/xxxxxxxxxxx/xxxxxfrm.aspx?BookID=" Then
                Exit Do
        End If
        WScript.Sleep 500
        If ie Is Nothing Then Exit Do
    Loop
End If

'ie.Visible = False

 

'初始随机值
intKey1 = Int(Second(Now()) / 10) + 10
intKey2 = Second(Now())

bChk = True


Do While Not ie Is Nothing
    If Not ie Is Nothing And ie.document.Frames.length > 0 Then
     On Error Resume Next
        '找到计时器的Frame对应的页面
        If Left(ie.document.Frames(0).Frames.document.location, 55) = "http://xxxxx.xxxxxx.com.cn/xxxxxxxxxxx/xxxxxxTime.aspx" Then
         
            On Error GoTo 0

            '找到计时页面上的当时时间
            strVal = ie.document.Frames(0).Frames.document.All("thzt").Value
            If bChk Then
              '修改按钮文本,原来是'更新计时'
                ie.document.Frames(0).Frames.document.All("update").Value = "监视时长:" & intKey1 & "分" & intKey2 & "秒"
                bChk = False
                WScript.Sleep 1000*60*intKey1
            End If

            'If Not ie Is Nothing And Not button Is Nothing And Not ie.document.Frames(0).Frames.document.All("update").disabled Then
                If strVal <> "" Then
                   

                     '时间到
                     If Left(Trim(strVal),2) > intKey1 Or Trim(strVal) = intKey1 & "分" & intKey2 & "秒" Or _

                             Trim(strVal) = intKey1 & "分" & intKey2+1 & "秒" Or Trim(strVal) = intKey1 & "分" & intKey2+2 & "秒" Then
                   
                        '随机值
                        intKey1 = Int(Rnd(Second(Now())) * 10) + 10
                        intKey2 = Int(Rnd(Second(Now())) * 60)
                       

                        '自动点计时按钮
                        ie.document.Frames(0).Frames.document.All("update").disabled=False
                        ie.document.Frames(0).Frames.document.All("update").Click
                        bChk = True
     
                        'MsgBox  "监视时长:" & intKey1 & "分" & intKey2 & "秒"
                    End If
                End If
               
            'End If
        End If
    End If
    WScript.Sleep 1200
    If ie Is Nothing Then Exit Do
Loop

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值