|
-
Apr 19th, 2009, 12:26 AM
#1
Thread Starter
Member
[RESOLVED] Webbrowser - Invoke click without having a name?
Alright, all I want to do is submit a form on this website.
The program is simple enough - automatically logs me into the site.
For reference; the website is ( http://kingsofchaos.com )
I know, the game is lame.. I enjoy it though xD
Anyway, I have already figured out how to fill in User/Pass fields.
But I am having problems understanding how to access the Login button.
It should be simple, but the button itself is not assigned a name at all.
Here is the only information given on the button itself ><
Code:
<input class="login_input" value="Login" style="width: 50px;" type="submit">
WebBrowser1.Document.All(" -?- ").InvokeMember("click")
^ This is the code I assume would work pending it had a name.
How ever, it does not have a name - so what do I do?
If anyone knows any alternative methods I would really appreciate it.
Thanks in advance!
-
Apr 19th, 2009, 08:07 AM
#2
Addicted Member
Re: Webbrowser - Invoke click without having a name?
use diff identifier
Code:
For Each he As HtmlElement In WebBrowser1.Document.All
If he.GetAttribute("value") = "Login" Then
he.InvokeMember("click").ToString()
Thats it mate
-
Apr 20th, 2009, 12:36 PM
#3
Re: Webbrowser - Invoke click without having a name?
Don't forget to exit the loop after invoking the click on the button. Otherwise, you may end up submittingthe form more than once (some web pages has more than 1 submit buttons on them).
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Apr 20th, 2009, 12:47 PM
#4
Re: Webbrowser - Invoke click without having a name?
you could also grab the form element and call its submit method, versus grabbing the submit button element, and callings its click method.
-
Apr 21st, 2009, 03:06 AM
#5
Thread Starter
Member
Re: Webbrowser - Invoke click without having a name?
Michalss example worked perfectly, well almost perfectly! 
Code:
For Each Unit As HtmlElement In WebBrowser1.Document.All
If Unit.GetAttribute("value") = "Login" Then
he.InvokeMember("click")
End If
Next
^ This is the actual code that I am using in my application.
Works perfectly, does exactly what I wanted it to.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|