Link to home
Start Free TrialLog in
Avatar of daypro
daypro

asked on

vb6 InternetExplorer.application auto submit click

I Can use vb6 code auto fill user_id,user_code ,and password in webpage of   https://eservice.chinalife.com.tw/sso/loginContent.jsp 
when I manual mouse click login button it works ok

but using 'MyIE.Document.Forms(0).submit auto submit
it shows error message like security reason ,time out

how do I using vb6 program code to auto click login,
"https://eservice.chinalife.com.tw/sso/loginContent.jsp "

thanks.
 
'-------VB6 CODE Begin
Private Sub Command1_Click()
sUrl = "https://eservice.chinalife.com.tw/sso/loginContent.jsp"
Set MyIE = CreateObject("InternetExplorer.application")
MyIE.Navigate (sUrl)

Do While MyIE.Busy And Not MyIE.ReadyState = 4
DoEvents
Loop

MyIE.Document.Forms(0).user_id.Value = "T120122924"
MyIE.Document.Forms(0).user_code.Value = "99580212"
MyIE.Document.Forms(0).Password.Value = "11111111"
'MyIE.Document.Forms(0).submit

MyIE.visible = True
End Sub

Avatar of nffvrxqgrcfqvvc
nffvrxqgrcfqvvc

You can try the example below appears to submit but I can't read the site :(
Option Explicit
   
Public Sub myChina(ByVal szUser As String, ByVal szCode As String, ByVal szPass As String)
  Dim IE As Object
  Set IE = CreateObject("InternetExplorer.Application")
  IE.Visible = True
  IE.Navigate "https://eservice.chinalife.com.tw/sso/loginContent.jsp"
  ' Wait for the page to load.
  Do While IE.Busy Or IE.ReadyState <> 4
    DoEvents
  Loop
  IE.Document.getElementById("user_id").Value = szUser
  IE.Document.getElementById("user_code").Value = szCode
  IE.Document.getElementById("password").Value = szPass
  IE.Document.getElementById("loginForm").Submit
  Set IE = Nothing
End Sub
  
  
Private Sub Command1_Click()
  
  myChina "username", "12345", "111111"
  
End Sub

Open in new window

Avatar of aelatik
cant you do someting with url posts like :

https://eservice.chinalife.com.tw/sso/PruServlet?type=iPC&module=SYSTEM&purpose=LOGON&user_id=T120122924&user_code=99580212&user_password=11111111

And in your form you are missing some paramters. The site contains 3 hidden items which or neccesarry to logon, these are set by a javascript when submitted.

type=iPC&module=SYSTEM&purpose=LOGON
Avatar of daypro

ASKER

I try manual click
 https://eservice.chinalife.com.tw/sso/PruServlet?type=iPC&module=SYSTEM&purpose=LOGON&user_id=T120122924&user_code=99580212&user_password=11111111
and try below code
but IE all show error message "Data base error"
-----

attach second  file insu2.gif is manual mouse click  result ok screen shot

-----------------vb6  code (still have problem,( IE show Data BASE ERROR)
Private Sub Command9_Click()
      URL_STR = "https://eservice.chinalife.com.tw/sso/PruServlet?type=iPC&module=SYSTEM&purpose=LOGON&user_id=T120122924&user_code=99580212&user_password=11111111"
   Dim IE As Object
  Set IE = CreateObject("InternetExplorer.Application")
  IE.visible = True
  IE.Navigate URL_STR
  ' Wait for the page to load.
  Do While IE.Busy Or IE.ReadyState <> 4
    DoEvents
  Loop
   Set IE = Nothing
End Sub

insu1.GIF
insu2.GIF
ASKER CERTIFIED SOLUTION
Avatar of aelatik
aelatik
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you realy wish to click that image then you can use the following. The image input has no ID so we need to find it on the form.

Public Sub myChina(ByVal szUser As String, ByVal szCode As String, ByVal szPass As String)
  Dim IE As Object
  Set IE = CreateObject("InternetExplorer.Application")
  IE.Visible = True
  IE.Navigate "https://eservice.chinalife.com.tw/sso/loginContent.jsp"
  ' Wait for the page to load.
  Do While IE.Busy Or IE.ReadyState <> 4
    DoEvents
  Loop
  IE.Document.getElementById("user_id").Value = szUser
  IE.Document.getElementById("user_code").Value = szCode
  IE.Document.getElementById("password").Value = szPass
  IE.Document.getElementById("type").Value = "iPC"
  IE.Document.getElementById("module").Value = "SYSTEM"
  IE.Document.getElementById("purpose").Value = "LOGON"
 
 
  ' Find the image that can perform a submit, the image has no id so we have to go through all input elements to find it
  For i = 0 To IE.Document.getElementsByTagName("input").Length - 1
    If IE.Document.getElementsByTagName("input")(i).Type = "image" Then
        On Error Resume Next
        If Right(IE.Document.getElementsByTagName("input")(i).src, Len("btn_login.gif")) = "btn_login.gif" Then
            IE.Document.getElementsByTagName("input")(i).Click
            Exit For
        End If
        On Error GoTo 0
    End If
  Next
 
  Set IE = Nothing
End Sub
 
 
Private Sub Command1_Click()
 
  myChina "username", "12345", "111111"
 
End Sub

But this gives the same results as my previous post.
Avatar of daypro

ASKER

Thanks aelatik
It's really a wanderful solution