Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[VB.NET] Click button without ID (WebBrowser Control) [VB.NET]

I saw that many people can't find a way to click a button without ID in WebBrowser control, so here is a solution! 🤗
I've created a function that will do that!

Code
'Author: H3x0S
'Release Date: June/27/2010

Public Function ClickWBElement(ByVal TagName As String, ByVal Attribute As String, ByVal AttributeContains As String)
  Dim ElCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName(TagName)
  For Each Element As HtmlElement In ElCollection
    If Element.GetAttribute(Attribute).Contains(AttributeContains) Then
    Element.InvokeMember("click")
    End If
  Next
  ClickWBElement = True
    End Function

Usage:

Code
ClickWBElement("BUTTON", "ATRIBUTE", "ATRIBUTETEXT")

Explanation:

Let's say that you have a button that doesn't have an ID.
Button code is:

Code
<button class="login">LOGIN</button>


You would use this function like this:

Code
ClickWBElement("button", "class", "login")

Thanks to Eleqtriq for inspiration.

PLEASE GIVE CREDITS IF USED!
Nice Function. +rep for you.
(Jun 27, 2010 12:08 PM)DarkSeven46 Wrote:  Nice Function. +rep for you.

Thank you. I am in a good mood today. 🙂
bookmared Was searching for this :)
(Jun 27, 2010 12:17 PM)HackFox Wrote:  *bookmared* Was searching for this :)

I saw many threads about this. That is why I created this function.
(Jun 27, 2010 12:18 PM)H3x0S Wrote:  I saw many threads about this. That is why I created this function.

I created a gmail function. where instead of having to change the code. It works like this, as a function:

Code
GmailSend("[email protected]", "Password", "[email protected]", "Subject", "Message")

And a test function:

Code
GmailTest("[email protected]", "Password")

Where is the function? That is just a usage. 🙂
Make a thread about it.
awsome i will check this soon i finish my logger
nice one dude, i remmeber when i had this problem with an old program of mine, and i did something similar, but it was way longer code than this,yours seems much more efficient! nice one, kudos to you
(Jun 27, 2010 12:29 PM)H3x0S Wrote:  Where is the function? That is just a usage. 🙂
Make a thread about it.

Ok, I will call it Gmail Functions.
(Jun 27, 2010 12:34 PM)DarkSeven46 Wrote:  Ok, I will call it Gmail Functions.

Yea, that is good. Functions FTW.
(Jun 27, 2010 12:42 PM)H3x0S Wrote:  Yea, that is good. Functions FTW.

Ok made thread. I think its above you thread, wait never mind. Its below you thread.
BumpBumpBumpBumpBumpBump!
Funny if there are two or more buttons VERY similar ~
But interesting code anyhow.
[Image: Xtddh8V.png]
(Jun 28, 2010 04:53 AM)Fake. Wrote:  Funny if there are two or more buttons VERY similar ~
But interesting code anyhow.

Thank you. This is very useful function.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by The Pulp FictionApr 24, 2022 12:22 AM 2 198 Apr 24, 2022 12:22 AM
Last Post: The Pulp Fiction
[.NET] by triplextremeSep 15, 2020 02:29 PM 7 220 Sep 15, 2020 02:29 PM
Last Post: Dredd
[.NET] by requiredhqMay 27, 2020 08:38 AM 2 104 May 27, 2020 08:38 AM
Last Post: Yui Hirasawa