Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

vb6 InternetExplorer.application auto submit click

Posted on 2009-12-21
6
Medium Priority
?
4,239 Views
Last Modified: 2012-05-08
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

0
Comment
Question by:daypro
  • 3
  • 2
6 Comments
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 26095736
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

0
 
LVL 14

Expert Comment

by:aelatik
ID: 26098737
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
0
 

Author Comment

by:daypro
ID: 26101408
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
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 14

Accepted Solution

by:
aelatik earned 2000 total points
ID: 26102760
ok, the main problem i'm having here is that i do not understand what the messages are which are displayed after performing actions. This piece of code gives a different result, try it and let me know.

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"
  IE.Document.getElementById("loginForm").Submit
 
  Set IE = Nothing
End Sub
0
 
LVL 14

Expert Comment

by:aelatik
ID: 26102796
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.
0
 

Author Comment

by:daypro
ID: 26102817
Thanks aelatik
It's really a wanderful solution
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question