Results 1 to 2 of 2

Thread: Need help with the Web Browser Control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100

    Post

    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:
    <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
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    I'm not sure whether this will work but you coul try this:

    Disable tabs so you can tab between fields on Web Page,

    load usename into the clipboard,
    use Sendkeys to tab to the text field,
    use sendkeys to paste username from clipboard,

    do the same for password,

    and tab to the Send button,
    sendkeys to activate it,

    re-enable Form tabstops.

    here's the code to disable tabstops so you can sendkeys tab to th eweb page:
    Code:
    to send keys tab to the elements within html in a webbrowser control do this:
    Option Explicit
    Dim arrTabStop() As Boolean
    
    Private Sub WebBrowser1_GotFocus()
    Dim i As Integer
    'Store the TabStop property for each control on the
    'form and then set the TabStop property of each
    'control to False
    ReDim arrTabStop(0 To Controls.Count - 1) As Boolean
    For i = 0 To Controls.Count - 1
    arrTabStop(i) = Controls(i).TabStop
    Controls(i).TabStop = False
    Next
    End Sub
    
    Private Sub WebBrowser1_LostFocus()
    
    Dim i As Integer
    'Restore the Tabstop property for each control on the form
    For i = 0 To Controls.Count - 1
    Controls(i).TabStop = arrTabStop(i)
    Next
    End Sub
    
    Private Sub Command1_Click()
    'this will tab through the elements within 'the html
    WebBrowser1.SetFocus
    SendKeys "{Tab}"
    End Sub


    ------------------
    Mark Sreeves
    Analyst Programmer

    [email protected]
    A BMW Group Company

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