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("https://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("https://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("https://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.