Hack Forums
[.NET] (TuT) How to click a button that doesn’t have an ID in Webbrowser (/TuT) (VB.NET) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] (TuT) How to click a button that doesn’t have an ID in Webbrowser (/TuT) (VB.NET) (/showthread.php?tid=1323608)



(TuT) How to click a button that doesn’t have an ID in Webbrowser (/TuT) (VB.NET) - E.T - May 26, 2011

Hello g,

This tutorial will show you how to click a button that doesn’t have an ID. You just need the button's name.

1. Requirement :

- a computer (lol)
- a Visual Basic Project with : a form,
a webbrowser, and
_ a button.

2. Start tutorial :

A. Just put in Form_Load :
Code
WebBrowser1.Navigate("http://login.facebook.com/login.php")

B. In Button_Click put :
Code
Dim a As HtmlElementCollection = WebBrowser1.Document.All

For Each b As HtmlElement In a
    If b.GetAttribute("value") = "Log In" Then

    b.InvokeMember("click")

    End If
  Next

Source : http://howtostartprogramming.com/vb-net/vb-net-tutorial-49-click-button-without-id/

I hope you like this tutorial
Sorry for my bad english :/



* - Rawe - May 26, 2011

no add to the TUT on how to do without a ID or a Value


* - 1NV1518L3 - May 26, 2011


For Each Elements As HtmlElement In WebBrowser1.Document.All()
If Elements.GetAttribute("name") Like "submit" Then
Elements.InvokeMember("click")
End If
Next


* - Uncol Dolan - May 27, 2011

(May 26, 2011 11:59 PM)Hell Guardian Wrote:  This is not a tutorial
You just copied/Pasted the code and didn't even comment it
Your "Method" won't work with every site
Because you can't guarantee that the Log In button Value will be "Log In"

You just change Log In To your needs...


* - Uncol Dolan - May 27, 2011

(May 27, 2011 01:41 AM)Hell Guardian Wrote:  What if the button doesn't have a value?
all I'm saying that this is not a tutorial as he doesn't even understand that code
I'm not trying to be an ass 😧
I just believe he just copied / Pasted the code

Oh, could be mate, i was making a bot maybe a week ago, and i needed this function... So this is really good thing, and you can use it to click pictures that are buttons :)


* - Hell Guardian - May 27, 2011

(May 27, 2011 01:42 AM)iMadafaka Wrote:  Oh, could be mate, i was making a bot maybe a week ago, and i needed this function... So this is really good thing, and you can use it to click pictures that are buttons :)
You can get the Html element "Any thing not only buttons" by various ways
Title
Src
Name
Alt
Type
Value
etc
So i was just pointing that out 😊



* - E.T - May 27, 2011

I just want to help you :(
If this tut is not good, i will delete it ...


* - shizzle08 - Jun 14, 2011

can you find the right attributes of update review button on facebook game review