[TUT] Webbrowser Textbox/Button/Checkbox

Posts 1–9 of 9 · Page 1 of 1
[TUT] Webbrowser Textbox/Button/Checkbox
I'm basically going to teach you how to fill in data on a website.

For instance on MPGH.

We want our VB Application to connect to MPGH - MultiPlayer Game Hacking - Hack Hacks Downloads, Combat Arms Hacks, CrossFire Hacks, WarRock Hacks, Soldier Front Hacks, Sudden Attack Hacks, Operation 7 Hacks, AVA Hacks, Battlefield Hacks, Bad Company 2 Hacks, Call of Duty Hacks, Modern Warf and then fill in the ID/PW for us + hit the login button.

First off all, we are going to take a deeper look into the source code of MPGH.

We righ***ick on the textbox where to put the id in and hit "Research Element"(or whatever it is called in English). If you are using internet explorer/firefox/safari simply righ***1ck on the website and hit - View Source -

Let us continue using google chrome. So, we righ***1ck on the user textbox and hit "Research Element".



Afterwards, we are going to get this window, with the current textbox as source marked:



Code:
<input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="User Name" onfocus="if (this.value == 'User Name') this.value = '';">
id="navbar_username"

We need the ID.

Let's go into VB.

Start a new project and call it whatever you want.



Drag & Drop a "Webbrowser" control on your form.

By default, the webbrowser is docked to all sides and is named "Webbrowser1".

Now double click on your form and you will see the source code of your vb project:

Code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

Form1_Load event obviously handles the action which is taken when the program is started.

Navigating your browser to a specific website

We are going to navigate the webbrowser to our mpgh site in order to login.

Code:
Webbrowser1.Navigate("http://www.mpgh.net/forum/")
I think this does not need any further explanation.

Moving on, we drag & drop a button on the form. If it does not work:

Click on the Webbrowser control on your form and look at the extreme upper right corner ">"



Now, you are actually able to drag & drop a button on your form.

By doubleclicking on your button you will now see your source code again:

Code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("http://www.mpgh.net/forum/")
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    End Sub
End Class
Filling in a username

On button_click event we want to fill in the username to the website.

Therefore, we need the following code:

Code:
Webbrowser1.Document.GetElementById("ID of the element").InnerText = "Whatever"
->

Code:
Webbrowser1.Document.GetElementById("navbar_username").InnerText = "Blubb1337"
If you want to be sure that the page is loaded when the data is filled in you can actually use the following code on form_load event:

Code:
  While Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete
            Button1.Enabled = False
        End While

        Button1.Enabled = True
Filling in the password is going to be the same. You can figure out on your own.

Checking a Checkbox

Easy-method:

Code:
<input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c">
Code:
Webbrowser1.Document.GetElementById("cb_cookieuser_navbar").Focus
Sendkeys.Send(" ") ' sending a space
Our how code looks like this now:

Code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("http://www.mpgh.net/forum/")

        While Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete
            Button1.Enabled = False
        End While

        Button1.Enabled = True
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        WebBrowser1.Document.GetElementById("navbar_username").InnerText = "Blubb1337"

        WebBrowser1.Document.GetElementById("cb_cookieuser_navbar").Focus()
        SendKeys.Send(" ")
    End Sub
End Class
Clicking a button

Either

WebBrowser1.Document.GetElementById("btn").InvokeM ember("click")

WebBrowser1.Document.GetElementById("btn").InvokeM ember("submit")

or

WebBrowser1.Document.Forms(0).Invoke("click")

WebBrowser1.Document.Forms(0).Invoke("submit")

SetAttributes

When looking at a source of a element it looks like this:

Code:
<input id="imembernamelive" name="imembernamelive" type="text" maxlength="64" value="" onfocus="SignUp.ShowHelp('wlid')" onchange="SignUp.ValidateField(this)">
value=""

What we want to do is set the attribute "value" to something.

To do that we need the following code:

Code:
Webbrowser1.Document.GetElementById("imembernamelive").SetAttribute(attributename as string, value as string)
->

Code:
Webbrowser1.Document.GetElementById("imembernamelive").SetAttribute("value", "Your username")
So you can now check/uncheck a checkbox using SetAttribute.

Code:
<input type="checkbox" id="iOptinEmail" checked="false">
Code:
Webbrowser1.Document.GetElementById("IOptinEmail").SetAttribute("checked", "true")
__________________________________________________ ___________

I just quickly wrote this tutorial up.

I do recommend you to use Google Chrome

This is it for now =D

I hope you did understand all.

I do know that my English is a bit crappy in the beginning

However, enjoy!

Please post additional information.
never knew you could do that with Chrome

Thanks for the useful tutorial.
Google Chrome comes in VERY handy in this case. You don't really have to search the ids =D
Wow I like you're current browser?

You made that?

MINION!

xD
It's google chrome >_< =D

SetAttributes

When looking at a source of a element it looks like this:

Code:
<input id="imembernamelive" name="imembernamelive" type="text" maxlength="64" value="" onfocus="SignUp.ShowHelp('wlid')" onchange="SignUp.ValidateField(this)">
Code:
vale=""
What we want to do is set the attribute "value" to something.

To do that we need the following code:

Code:
Webbrowser1.Document.GetElementById("imembernamelive").SetAttribute(attributename as string, value as string)
->

Code:
Webbrowser1.Document.GetElementById("imembernamelive").SetAttribute("value", "Your username")
So you can now check/uncheck a checkbox using SetAttribute.

Code:
<input type="checkbox" id="iOptinEmail" checked="false">
Code:
Webbrowser1.Document.GetElementById("IOptinEmail").SetAttribute("checked", "true")
HA HA, Google Chrome = Rocks

Anyway, thanks for sharing
hey could you explaine combo box's please -.- i dont get them
Quote Originally Posted by kaziboy View Post
hey could you explaine combo box's please -.- i dont get them
GTFO and stop bumping ancient threads.
Closed due to bump :\
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?