Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending input to an HTML form when controlling IE from VBscript

Status
Not open for further replies.

Springy

Programmer
Oct 20, 2000
5
GB
I want to automate the logon proces for a website. I can open IE from vbscript and make it load the page I want but I can't use the sendKeys function to input text into the username box. Does anyone have a way of getting the text in the HTML form and submiting it?


Springy, [sig][/sig]
 
Not really sure what you want to do but I just made a Login page. The receiving page has to be .ASP

On your login page in the form have two text boxes and a Submit button.
I called my text boxes Login and Password.

here is the form code for that.
-----------------------------------
Code:
<form action=&quot;page_your_calling.asp&quot; method=get>
  <p align=&quot;center&quot;><font size=&quot;5&quot;>Test Login Form</font></p>
  <p align=&quot;center&quot;>       Login <input type=&quot;text&quot; name=&quot;login&quot; size=&quot;20&quot;></p>
  <p align=&quot;center&quot;>Password <input type=&quot;text&quot; name=&quot;password&quot; size=&quot;20&quot;></p>
  <p align=&quot;center&quot;><input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;LoginButton&quot;><input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;B2&quot;>  
  </p>
</form>
-------------------------------

On the recieving page here is the code to check the login in SQL database.
---------------------------------
'the request.querystring(&quot;login&quot;) is the exact same name as the text box on the previous pages form.
Code:
<%login=request.querystring(&quot;login&quot;)%>  
<%pass=request.querystring(&quot;password&quot;)%>

<br>
<%
Set Conn = server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open &quot;driver=SQL Server;server=yourserver.com;uid=yyyy;pwd=xxx;database=yourdatabase;&quot;
Set RS1 = Conn.Execute(&quot;SELECT * From Customers Where [WEBLogin] = '&quot; & login & &quot;' AND [WEBPassword] ='&quot; & pass & &quot;'&quot;)
<%
If Not RS1.EOF Then%>   
' Now if the have a vaild login then do what ever here

<%Else
    ' have a link to take them back and try again
Response.Write(&quot;Sorry Invalid Login&quot;)%>
	 <a href=&quot;login.asp&quot;>Retry Login</a>
	 <%Response.Write(&quot;Or Call whoever at 1-999-999-9999 for a Login&quot;)
End If
%>

---------------------------------------------------

The following is passed in the Address from the first page to the second when thye click the submit button.
------------------
-----------------------
Which is simply the name of the .ASP you are calling and a ? mark and the exact names of the textboxes
then = sign then what was keyed in the textbox then & ampersand and the next textbox and so forth.
The login in button name is passed but I'm not doing anything with it.

B-)

[sig]<p>DougP, MCP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.[/sig]
 
Not quite what I wanted to know!!

Right i'll tell you what i've got.

I use this line to open up IE:

Set ie = Script.CreateObject &quot;InternetExplorer.Application&quot;)

I then use this line to make IE open the page I want:

ie.Navigate &quot;
I then wait for my page to open. Once the page is open I want to be able to put some text into the input boxes. SendKeys seems the most likely call to use but I get errors saying sendKeys is not supported.

SO my question to all you lot out there is what can I use to put the text into the input box. (NO ASP ANSWERS PLEASE)


Okey Dokey

Springy.....
 
Springy,
Don't use sendkeys, use the IE object to control the web page:

Set ie = Script.CreateObject &quot;InternetExplorer.Application&quot;)
ie.Navigate &quot;
do while ie.busy
'wait for document to finish loading
loop
ie.document.forms(0).UserName.value=&quot;springy&quot;
ie.document.forms(0).Password.value=&quot;pwd&quot;
ie.document.forms(0).submit

nick bulka
 
I also want to do that but, the user and password need to be input in a popup windows that opens when I access the page.
How do I send the user and password to the window popup?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top