Click to See Complete Forum and Search --> : detect and fill editboxes in Internet Explorer automatically


ashrobo
April 14th, 2004, 08:43 AM
hi,
i have a MFC dialog application and i have to go to a predefined website (say, www.codeguru.com) with Internet Explorer, detect the log in editboxes, and automatically fill them up with details from my application.

anyone has any idea how this can be done?

thanks!
-ashrobo

edited to add: just realised there are many automated form filler out there. anyone has experienced writing those applications?

Kheun
April 14th, 2004, 08:00 PM
Are you referring to sending a http form to a http server? Other launching IE and fill up the form before sending, you can write code to open a socket and send a http 'POST' request directly to the server.

ashrobo
April 14th, 2004, 08:25 PM
Originally posted by Kheun
Are you referring to sending a http form to a http server? Other launching IE and fill up the form before sending, you can write code to open a socket and send a http 'POST' request directly to the server.

i haven't thought of it as "sending a http form to a http server" actually, what i had been thinking was just "mimicking the steps that a user will take to log in to a website, say this forum" - i.e. to open up internet explorer, type the url in the bar, fill in the 2 editboxes, and click enter.

hope you can elaborate more.. (=

thanks!
-ashrobo

Kheun
April 14th, 2004, 08:54 PM
Actually, sending http POST request directly to the server is quite common. There are many existing applications that allow user to register his/her copy using the same mechanism.

The actual working is exactly like that of a webbrowser. That is, when the user clicks on submit, the webbrowser creates a http POST request and sends it to the server. So in your implementation you can also the same thing when all data is available to you. In fact, it is much simpler in implementation and you can capture the data in anyway you like without restricting yourself only to a webbrowser. For more details on the http and http POST protocol, you can search at http://www.w3.org/.

ashrobo
April 14th, 2004, 11:08 PM
actually, i dont quite get it.

do you have a working example of some sort?

Kheun
April 15th, 2004, 12:22 AM
Let me try to phrase it differently. Probably, you have already known, the transport layer is TCP/IP which helps to send the bits for the data over the network. On top of the TCP/IP layer is HTTP. HTTP is an application layer protocol which is used for transfer the HTML file. If the web site is not available, it is also this protocol that tell your browser the error message, like 404 error. If everything works fine, then you can see the webpage, which is represented by HTML, on your browser. The HTTP also provide several other services and one of them is POST. Through the POST, we are enable to submit information on the HTML form to the designated server. Looking at your original workflow, it is exactly what you want to do right after mimicking the data entry by the user. Rather then mimicking, you can skip it and you go down to the HTTP layer for sending out the information directly.

The code for the HTTP POST is pretty straigth forward. Unfortunately I don't have any available code at the moment. When implementing, you are require to open a TCP/IP socket connection, create the POST request in a buffer and then send it out to the server.

Hope this helps.

Kheun
April 15th, 2004, 12:29 AM
I just found a sample here.

http://www.codeguru.com/Cpp/I-N/internet/http/article.php/c6193/

ashrobo
April 15th, 2004, 05:02 AM
Kheun, thanks for all the help.
I guess I must be really dumb, I can't even figure out how to send data to the server through POST using the the sample.

Kheun
April 15th, 2004, 05:27 AM
Oops, a thousand apologies for giving the wrong direction... It is really my fault. As I was searching for it in a hurry, I didn't look at the code and it turn out to be using COM object... Sorry again. :blush:

You may like to try your luck at www.codeproject.com. It has many sample codes that may be helpful.

ashrobo
April 15th, 2004, 06:47 AM
no worries. (=

no one has tried this before?

-ashrobo