webbrowser automating

Posts 1–13 of 13 · Page 1 of 1
webbrowser automating
im going to post a bunch of code on webbrowser automating that i used to use when i just started learnign before i got into webrequest
Click A Button
Code:
webbrowser1.Document.All("Button ID").InvokeMember("click")
IF ID Exists
Code:
 If WebBrowser1.Document.All("ID") Is Nothing Then
   Else
            MsgBox("ID  exsits")
        End If
Click Button Just By Value Of It
Code:
Private Function GetBtnByValue(ByVal value As String) As HtmlElement
        For Each d As HtmlElement In Webbrowser1.Document.GetElementsByTagName("input")
            If (d.GetAttribute("type").ToLower = asd.Text Or d.GetAttribute("type").ToLower = "submit") Then
                If (d.GetAttribute("value") = value) Then
                    Return d
                    Exit For
                End If
            End If
        Next
    End Function
    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        GetBtnByValue("go").InvokeMember("Click")
    End Sub
Click Check box
Code:
   Dim outer As String = WebBrowser1.Document.All("PersistentCookie").OuterHtml
        WebBrowser1.Document.All("Check Box ID").OuterHtml = outer.Remove(outer.Length - 2) + " checked>"
Click all Check box's with same value
Code:
 For Each InputBx As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
            If (InputBx.GetAttribute("type").ToLower = "radio") AndAlso (InputBx.GetAttribute("value").ToLower = "Value Of Check Box") Then
                InputBx.InvokeMember("Click")
            End If
        Next
Fill Textbox In Webbrowser
Code:
For Each HTMLele As HtmlElement In WebBrowser1.Document.All
 If HTMLele.Name = "ID" Then
   HTMLele.SetAttribute("value", "someemail@somewhere.comValue")
  End If
 Next
Get Text From Textbox In Webbrowser
Code:
        Dim text As String = WebBrowser1.Document.All("Textbox ID).GetAttribute("value")
  TextBox1.Text = text
Stop IE Pop ups
Code:
WebBrowser1.ScriptErrorsSuppressed = True
Check URL
Code:
 If WebBrowser1.Url.ToString = "URL" Then
webbrowser contains
Code:
 If WebBrowser1.DocumentText.Contains("Phrase") Then
        Else
        End If
Webbrowser status
Code:
 TextBox1.Text = WebBrowser1.StatusText
Show Page Source
Code:
  TextBox1.Text = webBrowser.Document.body.innerHTML
Download Page
Code:
        Dim MyWebClient As New System.Net.WebClient()
        TextBox1.Text = MyWebClient.DownloadString("URL")
oouuuhh pretty, whats it do
Quote Originally Posted by Liz View Post
oouuuhh pretty, whats it do
just codes so if you want to make a bot to do an automated task for you
oh ouh, would this work with grease monkey?
Quote Originally Posted by Liz View Post
oh ouh, would this work with grease monkey?
no this is vb 2008 code
gotcha, thanks ^^
Will this work on runescape?
I need a more clear idea of this... Im very confused. Im still learning<------------chooby
No Pixie, it wont work on RuneScape, since RuneScape is made in Java.
And your webbrowser would never be able to acces the data in the RuneScape client.
If I got this right , These are codes there interact with "Tools > Webbrowser" that you can use to furfill a simple task such as...Filling in a title textbox...so say you wanted to go to this page "http://www.mpgh.net/forum/newreply.php?do=newreply&noquote=1&p=######" and Fill in "Title:" With Web Codes , then you can set it to click a button in your Visual Basic Browser and then it will automatically fill it in with the data , which can be very useful for saving password information and getting your details typed in on a click of a button.

Thanks , Was Very Useful information
Quote Originally Posted by K4GE View Post
No Pixie, it wont work on RuneScape, since RuneScape is made in Java.
And your webbrowser would never be able to acces the data in the RuneScape client.
there is ways to send silent mouse clicks to the java window
Well yes thats true, but you won't be able to do stuff like: filling forms, clicking buttons (without telling the location (X-Y)), and so on...
But yes, what your saying is possible.
Quote Originally Posted by K4GE View Post
Well yes thats true, but you won't be able to do stuff like: filling forms, clicking buttons (without telling the location (X-Y)), and so on...
But yes, what your saying is possible.
way easy all you need to do is find the button you want to click get the color of it and have vb get the x,y of the color and click that x,y ive done stuff like this many times
Posts 1–13 of 13 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Talk with us