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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating Internet Explorer 1

Status
Not open for further replies.

chpicker

Programmer
Apr 10, 2001
1,316
Does anyone know how to automatically enter data into a field and click a button using an automated IE browser in VFP? Here's an example of what I want to do:

--Create the IE object.
--Navigate to a web page using the Navigate method.
--When the page is finished loading, programatically enter username and password into the fields provided (these are in the page, not a dialog box), then click the LOG IN button.
--Once the login is complete and the new screen is up, programatically enter data from a table into the new screen and submit it (click another button)
--When the final page is loaded, retrieve the information given, maybe execute IE's PRINT method to send the page to the printer, and RELEASE the IE object.

I want to do all of this without the user ever seeing the web browser. However, I cannot find the methods in IE that would allow me to do this. Does anyone have suggestions? Is there a complete list of accessible automation methods for IE? I've tried searching MSDN/MS Knowledge Base, but didn't have much luck. I'm pretty open as to the implementation...I could use InternetExplorer.Application or the MSWebBrowser class...or anything else suggested.
 
If you have a little understanding of HTML & ASP or ColdFusion, you should be able to figure it out. For instance, here's some VFP automation of IE to log you into Tek-Tips:

oIE = CREATEOBJECT([InternetExplorer.Application])
oIE.Silent = .T.
oIE.Width = Sysmetric(1)
oIE.Height = Sysmetric(2)
STORE 0 TO oIE.Left,oIE.Top
oIE.Navigate([www.tek-tips.com])
WaitForIE()
oIE.Document.Forms(0).Handle.Value = [yourhandle]
oIE.Document.Forms(0).Pass.Value = [yourpassword]
oIE.Document.Forms(0).Submit
WaitForIE()
oIE.Visible = .T.
oIE.Silent = .F.
RELEASE oIE
RETURN

PROCEDURE WaitForIE
DO WHILE oIE.Busy OR oIE.ReadyState <> 4
DOEVENTS
ENDDO
ENDPROC

Retrieving the information, presuming its HTML ouput to the browser, shouldnt prove to difficult. If you could post a sample on your website with the url, someone might be able to figure it out. Jon Hawkins
 
Thanks, Jon. That helped a little, at least I know that what I want to do is possible. I tried your code out, and I was able to successfully automate a login to Tek-Tips.

The problem with trying to reproduce the system on the page involved is that I can't figure out the object names to manipulate. oIE.Document.Forms(0) doesn't evaluate to an object. oIE.Document.Frames(0) and .Frames(1) evaluate to objects named &quot;main&quot; and &quot;workSpace&quot;...but I haven't managed to find any other members than those, either directly under Document or under either of the Frames(). Looking through the Source, I found what looks like variables declared for the Username and Password fields, but I don't know Java so I am not sure how they would translate into assignment statements in VFP.

I realize it would be helpful if I posted the website, but unfortunately it's confidential, so any help you guys can offer is going to have to be blind. :eek:(
 
There is no way in the IE object allow you to do that.
Basicly you want to manipulate the web page programatically and this is out the scope of IE.
If you are the owner of this web page, it is easy to do it another way. if not you can use any scripting software to do this job for you. Let me know which way will fit your needs the best.
Thanks Walid Magd
Engwam@Hotmail.com
 
Contrary to Walid, I do think your request can be completed thru IE automation.

However, I do agree that there are easier ways to achieve this if you are the owner of the pages.

One way would be to use wwIPStuff to POST the form data.

Another would be to setup an ASP page to GET all the values from the url:

You make the http request thru IE, WinInet, wwIPStuff, etc...The ASP page returns plain text results (no html) to the client.

Another would be to setup XML messaging where the client sends the data as XML and the server sends back the response as XML.

I'd recommend you visit and read some of the articles on Distributed applications. Jon Hawkins
 
Unfortunately, I am NOT the owner of the page, but am a customer of the company that owns it. It is an information server that I must log into, then can perform queries on their data by typing text into the search fields and hitting the Search button.

The example of auto-logging into Tek-Tips by simply setting the username and password fields and programmatically triggering the submit button shows that what I want to do is not only possible but fairly simple is what inspires me to keep trying. All I should have to do is locate the correct object names. I was just hoping someone might have suggestions on better ways to look. I'll try sending an email to the site owner. Perhaps they might know.
 
You can automate IE to complete that task. I have written code that does exactly that. The only porblem I ran into is how to reference specific objects on the webpage. I ended up running the code with the debugger and tried adding objects to the watch window and seeing which values I got back. By manipulating the oie.DOCUMENT.SCRIPT.WINDOW.DOCUMENT.all.item(x) references, I was able to locate the exact object I needed to get where x is an index number of said object. Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top