1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim theElementCollection As HtmlElementCollection
theElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theElementCollection
Dim controlName As String = curElement.GetAttribute("name").ToString
If controlName = "username" Then
curElement.SetAttribute("Value", "textbox2.text")
ElseIf controlName = "message" Then
curElement.SetAttribute("Value", "textbox1.text")
'on peut recuperer la valeur des elements comme ca:
MessageBox.Show(curElement.GetAttribute("Value"))
End If
Next
' appuyer le bouton envoyer de facon automatique
theElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("value").Equals("envoyer") Then
curElement.InvokeMember("click")
End If
Next
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://www.i-tchat.com/?116303")
End Sub
End Class |
Partager