Results 1 to 3 of 3

Thread: Problem with Web Browser Control - Fill in a form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100

    Post

    Hi.

    I need some help with the Web Browser Control. You see. I want WB to fill in a form and then "POST" it like if you did it manually.

    As you can see in the example below I want my program to fill in the "username" and "password" and then POST the information.

    Can you please help me??? I'm desperate..

    Best regards Johan Ryberg, SWEDEN

    Example htmlpage:

    Code:
    <HTML>
    <HEAD>
    <SCRIPT>
    <!--
    	function newPane(fls_host) {
    		pageUrl = "http://" + fls_host + "/serviceSelection.php3";
    		window.open(pageUrl,"selection",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=300');
    	}
    //-->
    </SCRIPT>
    
    <SCRIPT>
    <!---
    var isButtonPressed = false;
    
    function flsSubmit() { 
         if (isButtonPressed == false) { 
    	  isButtonPressed = true;
    	  document.pwdenter.submit(); 
    	  } 
    }
    //-->
    </SCRIPT>
    
    	  
    
    
        <FORM NAME="pwdenter" ACTION="userlookup.php3" METHOD="POST">
    	  <INPUT NAME="timestamp" TYPE=HIDDEN VALUE="948816493">
          <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%" HEIGHT="100%">
            <TR><TD>
    	    <CENTER>
    	      <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
    		<TR><TD>
    		    <IMG SRC="telialogo.gif" ALT="logo" BORDER="0">
    		    
    		    <FONT SIZE="-1" FACE="Geneva, Arial">
    		      <BR><BR>
    		      		      Mata in ditt användarnamn och lösenord nedan.<BR>
    		      Tryck sedan på "Logga in".
    		      <BR><BR>
    		      Användarnamn:
    		      <BR><INPUT NAME="username"><BR>
    		      Lösenord:
    		      <BR><INPUT NAME="password" TYPE=PASSWORD onBlur="this.form.username.focus();">
    		      <BR>
            <INPUT TYPE="BUTTON" NAME="submitForm" VALUE="Logga in " onClick="flsSubmit() ">
    	      </TABLE>
          </TABLE>
        </FORM>
        
    </body>
    </HTML>

    ------------------
    Best Regards rancor
    [email protected]
    http://www.sajberhem.nu

  2. #2
    Lively Member
    Join Date
    Oct 1999
    Posts
    101

    Post

    Hi Johan,

    I believe that I can help you with this. Can you give me the URL of the web page that you want to fill in?

    If so, I'll create the code to do this for you.

    All the best.

    Chris

  3. #3
    Lively Member
    Join Date
    Oct 1999
    Posts
    101

    Post

    Hi Johan,

    Create a new VB project with a WebBrowser Control and 2 command buttons.

    Paste this code into the VB Editor:
    Code:
    Option Explicit
    
    Dim mICount As Integer
    Private Sub Command1_Click()
        mICount = 0
        WebBrowser1.Navigate2 "www.hotmail.com"
    End Sub
    
    Private Sub Command2_Click()
        Unload Me
        End
    End Sub
    
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
        If pDisp Is WebBrowser1.Object Then
            If mICount = 0 Then
                SendKeys "Hi Johan"
                SendKeys "{TAB 2}"
                SendKeys "password"
                SendKeys "{ENTER}"
                mICount = 1
            End If
        End If
    End Sub
    This will fill in the Hotmail Web Page and attempt to log you in. You should easily be able to modify the code to fit the Web Page you want to interact with. Let me know if you have any problems.

    All the best.

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width