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
IE窗体自动
最新推荐文章于 2023-11-05 03:05:57 发布