News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Simulating a HTML button click

Started by Robert Collins, May 03, 2005, 06:49:28 PM

Previous topic - Next topic

Robert Collins

I'm writing a simple program that uses the shdocvw.dll. I know how to fill in the HTML fields using the DLL but I don't know how to emulated the clicking of the submit button.

Can someone here put me in the right direction?

I hope I explained it correctly. Thanks

Tedd

Normally you'd post a BN_CLICKED message to the button. But this assumes you can get its handle..

Alternatively, you could fake the clicks with:
- SetCursorPos(...
- mouse_event(...

..but this requires you know where the button is :P
No snowflake in an avalanche feels responsible.

Robert Collins

Quote from: Tedd on May 04, 2005, 12:34:35 PM
Normally you'd post a BN_CLICKED message to the button. But this assumes you can get its handle..

Alternatively, you could fake the clicks with:
- SetCursorPos(...
- mouse_event(...

..but this requires you know where the button is :P

That's a little bit beyond my understanding. Maybe if I explain better. OK, the DLL has a method called 'Document' and this method has some properties which you can modify and thus in turn the DLL will modify the HTML document. For example, when I want to fill in some HTML text fields I would write the following code line:

Document.All("username").Value = "myname"
Document.All("password").Value = "mypasswd"


In the above example, username and password are the names of the text fields in the HTML document........


  .
  .
<input type="text" name="username" value="" size="14" maxlength="20">
<input type="text" name="password" value ="" size="14" maxlength="20">
  '
  '


In order to send the user name and password back to the server you must now click on the submit button or in some cases it's just a link.


  .
  .
<input type="text" name="username" value="" size="14" maxlength="20">
<input type="text" name="password" value ="" size="14" maxlength="20">
  '
  '
<input type="button" value="Login" .......>


Now I want to simulate the actual clicking of the submit button. Here is where I have my problem. I have no idea what the correct code line should be.

doomsday

Looks suspiciously like javascript.  I'd suggest trying some of the following:
document.all("FOOBUTTON").click()
document.FOOBUTTON.click()
document.forms["NAME_OF_FORM"].FOOBUTTON.click()
document.getElementByName("FOOBUTTON").click()
document.getElementByID("FOOBUTTON").click()


If none of those work, could you post a link to any documentation for the DLL you're using?

regards,
-Brent


AeroASM

Or you could use an API to redirect the browser straight to "somescript.asp?param1=value1&param2=value2..."

Robert Collins

Quote from: doomsday on May 04, 2005, 03:08:15 PM
Looks suspiciously like javascript.  I'd suggest trying some of the following:
document.all("FOOBUTTON").click()
document.FOOBUTTON.click()
document.forms["NAME_OF_FORM"].FOOBUTTON.click()
document.getElementByName("FOOBUTTON").click()
document.getElementByID("FOOBUTTON").click()


If none of those work, could you post a link to any documentation for the DLL you're using?

regards,
-Brent



No, it is not Java Script. I am writing a Windows application that, via the shdocvw.dll, allows you to load web pages into your application and then using certain dll call functions you can programatically place data in all fields that allow input data and also you can do alot of other neat things if you know how. I will try those examples that you posted. Unfortunatly I do not have any documentation on the DLL. Everything I know how to do I learned either by trial and error or someone somewhere posted an example of some of it's usage.

I should explain how I am using the dll. The dll can be used in one of two ways; either as a called dll like you would use in a C or an Assembly program by including the .lib file or you can use it as an OCX. I am using it as an OCX. The problem with the OCX is that it does not openly give you all the features of the DLL but if you know them you can implement them just as easy as the available documented features. The feature that I am using to place data in the text fields of the HTML document is one of those 'undocumented' features of the OCX. I just happened to know how to use them but I am lost as far as invoking the submit button and there is the possibility that there isn't one available anyway.           

tenkey

When you click a submit button, you send an HTTP request for a GET or POST. The FORM specifies which request will be sent to the web server. GET is the ordinary URL request, so you pass field data in the URL when requesting a GET, as in AeroASM's example. A POST request puts field data in a different part of the HTTP "packet", so you don't see the long-winded URL typical of GET requests.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

Robert Collins

I appreaciate your response in trying to help me but it is not what I am asking. I already know what occurs when you click on the submit button. My question is not how it works but how to emulate it using the DLL in an application. Doomsday had the right idea about what I am trying to do but none of his examples worked. I could, using complex code, produce the desired affects of the submit button but I would rather see if it can be done using a method of the DLL. I have searched the net and other resources but have been unable to find any documentation on the shdocvw.dll or as it is commonly known as the WebBrowser ActiceX control (OCX) that gets into the undocumented features of the DLL.

When you use the OCX in your application it in essense gives you a web browser window which has many documented features so you could basically make a browser application (like IE, for example). These documented features are great and gives you alot of functionality but they are very basic and do not get into the more intricate control of the web pages being loaded into the browser window. I have been able to pick up a few of the undocumented features through hit and miss but have yet to find out how to pass control to the DLL to tell it to "click" the submit button.

I guess to make my question more meaningful would be to ask if anyone knows when I might find some information on using the control or does anyone know what the command is to use so as to 'emulate' the click.   

P1

The Whole Click and nothing but the Click?    :lol

Seriously, the emulation is for the user's action of the click ( i.e. user has entered the information.  And you want to click for him? ) or for the whole transaction, where the dll supply all post data including the button action being pasted to the server.  ( i.e. No input or action is expected from the user? )

Regards,  P1  :8)


Robert Collins

Quote from: P1 on May 06, 2005, 01:34:48 PM
The Whole Click and nothing but the Click?    :lol

Seriously, the emulation is for the user's action of the click ( i.e. user has entered the information.  And you want to click for him? ) or for the whole transaction, where the dll supply all post data including the button action being pasted to the server.  ( i.e. No input or action is expected from the user? )

Regards,  P1  :8)



I'm really lost on this one. I must be asking the wrong thing. Oh well, I will keep looking for the answer. Somewhere out there I'm sure I will come accross it someday.

sluggy

OTTOMH, what you need to do is the equivalent of:

object blah = getElementByID('<yourID>');
blah.fireEvent('click');

In any case, i would search the VB forums and newsgroups, you will find thousands of posts regarding that dll.