IE窗体自动

Sub Main()

    Dim ie As InternetExplorer
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True


    ie.Navigate "login.asp"
    waitNavigation ie
    
    Set oName = ie.document.getElementsByName("LoginID")
    Set oPwd = ie.document.getElementsByName("PassWord")
    Set oLogin = ie.document.getElementsByName("btnLogin")
   
    
    oName(0).Value = username
    oPwd(0).Value = password
    oLogin(0).Click
    waitNavigation ie

    Set oManagePwd = ie.document.getElementsByName("ManagerPassWord")
    Set oLoginNew = ie.document.getElementsByName("NewPassWord")
    oManagePwd(0).Value = password
    oLoginNew(0).Click
    waitNavigation ie

    Set objFrames = ie.document.frames
    For i = 0 To objFrames.Length - 1
        If (objFrames(i).Name = "frameTop") Then
            Set objForms = objFrames(i).document.forms
            For j = 0 To objForms.Length - 1
                If (objForms(j).Name = "form") Then
                    For Each objTable In objForms(j).getElementsByTagName("table")
                        If (objTable.className = "head_plate") Then
                            For Each objUrl In objTable.getElementsByTagName("a")
                                If (objUrl.innerText = "xxxx") Then
                                    objUrl.Click
                                End If
                            Next objUrl
                        End If
                    Next objTable
                End If
            Next j
        End If
    Next i

    waitNavigation ie
    
    Set objFrames = ie.document.frames
    For i = 0 To objFrames.Length - 1
        If (objFrames(i).Name = "frameBtm") Then
            For Each objTable In objFrames(i).document.getElementsByTagName("table")
                If (objTable.className = "item") Then
                    For Each objUrl In objTable.getElementsByTagName("a")
                        If (InStr(1, objUrl.innerText, "xxxx", vbTextCompare)) Then
                            objUrl.Click
                        End If
                    Next objUrl
                End If
            Next objTable
        End If
    Next i
    
    waitNavigation ie
    Sleep (1000)
    Set objFrames = ie.document.frames
    For i = 0 To objFrames.Length - 1
        If (objFrames(i).Name = "frameBtm") Then
             For Each objInput In objFrames(i).document.getElementsByTagName("input")
                If (InStr(1, objInput.Value, "...", vbTextCompare) And objInput.Name = "xxxx") Then
                    objInput.Click
                End If
             Next objInput
        End If
    Next i
    
    waitNavigation ie
    Sleep (1000)
    
    Set ObjShells = CreateObject("Shell.Application")
    For Each objwindow In ObjShells.Windows
        If (TypeName(objwindow.document) = "HTMLDocument") Then
            If (InStr(1, objwindow.document.Title, "xxxx")) Then
                Set ie2 = objwindow
                Exit For
            End If
        End If
    Next objwindow
'    Call EnumWindows(AddressOf GetProc, 0)
    'ie is created a new object
    Set objFrames = ie2.document.frames
    For i = 0 To objFrames.Length - 1
        If (objFrames(i).Name = "FRAMEE") Then
             For Each objInput In objFrames(i).document.getElementsByTagName("input")
                If InStr(1, objInput.Name, "AllSel", vbTextCompare) Then
                    objInput.Click
                    Exit For
                End If
             Next objInput
             Sleep (1000)
             For Each objInput In objFrames(i).document.getElementsByTagName("input")
                If InStr(1, objInput.Name, "button", vbTextCompare) Then
                    objInput.Click
                    Exit For
                End If
             Next objInput
        End If
    Next i

End Sub


Function GetIE(ByVal hWnd As Long) As Long
    Dim Doc As IHTMLDocument2
    Dim s As String
    Set Doc = hWnd
    If Not Doc Is Nothing Then
        For Each objTitle In Doc.getElementsByTagName("input")
            If (InStr(1, objTitle.Value, "AllSel", vbTextCompare)) Then
                Debug.Print objTitle.Text
            End If
        Next objTitle
        Do Until Doc.readyState = "complete"
            DoEvents
        Loop
'        s = Doc.body.innerHTML

    End If
End Function


Public Function GetProc(ByVal hWnd As Long, lParam As Long) As Boolean
Dim MyName As String * 128
Dim ret As Long

MyName = ""
ret = GetWindowText(hWnd, MyName, Len(MyName))

If IsWindowVisible(hWnd) Then
If GetWindow(hWnd, GW_OWNER) = 0 Then
If ret <> 0 Then
    If InStr(1, MyName, "xxxx", vbTextCompare) Then
        Call GetIE(hWnd)
    End If
End If
End If
End If
GetProc = True
End Function

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值