PDA

Click to See Complete Forum and Search --> : Need help with the Web Browser Control


rancor
Jan 25th, 2000, 12:42 AM
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=30 0');
}
//-->
</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
rancor@sajberhem.nu
http://www.sajberhem.nu

Mark Sreeves
Jan 25th, 2000, 04:41 PM
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:

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

Mark.Sreeves@Softlab.co.uk
A BMW Group Company