[RESOLVED] Clicking a button on the Webbrowser.
OK guys :D, I know how to click a normal button with the Name property, but I have a listbox and a button next to it. I can select an item from the listbox - no problem, but I want to be able to click the button as well.
The code for the button is this:
Code:
<input class="btnlite" type="submit" value="Go" />
Could anyone help me?
Re: Clicking a button on the Webbrowser.
Is this button on a web page that you developed?
Re: Clicking a button on the Webbrowser.
Are you using a web browser control on your form to house the webpage? We need a bit more info.
Re: Clicking a button on the Webbrowser.
@ Hack:
No, I'm a mod on a site, and there's some quick-mod tools in a listbox. I'm trying to get it to lock the topic, which is one of the options in the listbox and then post a message saying it was locked.
I can make it post the message and change the listbox to the Lock one, but I can't figure out how to push that button.
Here is the entire code for the listbox and things.
HTML Code:
<td width="40%" valign="top" nowrap="nowrap" align="left"><form method="post" action="this goes to a mod page."><span class="gensmall">Quick-mod tools:</span> <select name="action" id="quick-mod-select"><option value="lock">Lock topic</option><option value="delete_topic">Delete topic</option><option value="move">Move topic</option><option value="split">Split topic</option><option value="merge">Merge posts</option><option value="merge_topic">Merge topic</option><option value="fork">Copy topic</option><option value="make_sticky">Change to “Sticky”</option><option value="make_announce">Change to “Announcement”</option><option value="make_global">Change to “Global”</option><option value="topic_logs">View logs</option></select> <input class="btnlite" type="submit" value="Go" /></form></td>
@Robdog:
Yes, the web browser is on my form. I click a button and the browser navigate to the login page, it logs in then it posts the locked message and then finally locks it (which I can't figure out how to do).
Re: Clicking a button on the Webbrowser.
You can use the documents DOM to submit the form (click button).
Some examples...
http://www.vbforums.com/showthread.php?t=330341
Re: Clicking a button on the Webbrowser.
I'll take a look, thanks :D
Re: Clicking a button on the Webbrowser.
I can't figure it out. Could you help me out a bit more? Cheers.
Re: Clicking a button on the Webbrowser.
This post of that thread has the DOM example.
http://www.vbforums.com/showpost.php...6&postcount=56
also, if your button has a name or id then you can simply...
WebBrowser1.Document.All.btnSubmit.Click
Re: Clicking a button on the Webbrowser.
Quote:
Originally Posted by RobDog888
Yeah, I knew about WebBrowser1.Document.All.btnSubmit.Click I use that to login, I think. The button doesn't have either of them, I don't think.
I had a look at the topic you gave me before, but the form still wasn't submitting. However, the site is getting a few 500 errors lately and that might be the reason.
I looked at this code in the project
'Submit the first (and only) form in the page
WebBrowser1.Document.Forms.Item(0).submit
but I don't know how I would integrate the html form into that.
The form starts like this, I think
<form method="post"
When I looked through the source code of the page, there was two other examples of this. Both of them were after the one I wanted. Do you know if it would be possible to submit the form using that code?
Re: Clicking a button on the Webbrowser.
Since there is no button name or id you may have to iterate through the elements to get the desired button. You could also do it the flakey way by using SendKeys but with IE7/Vista it wont work.
Re: Clicking a button on the Webbrowser.
Quote:
Originally Posted by RobDog888
Since there is no button name or id you may have to iterate through the elements to get the desired button. You could also do it the flakey way by using SendKeys but with IE7/Vista it wont work.
I guess I'll have to do that, then.
Thanks so much for your help :D