Bonjour voici un tutoriel pour vous faire un créateur de compte dofus a partir d'un web browser (je vais essayer commenter les ligne suite a la demande de lolodu92)
Je vais expliqué ce qui me semble le plus dur
1) Requis :
Il vous faut
-4 boutons
-5 textebox
- 3 NumericUpDown
2 ) Le nom des objets requis et leur utilités
Button1 : Compléter les champs
Button2 : Validé le captcha
Button3 : Générer les caractères
Button4: Enregistrer le compte
Textbox1 : Nom de compte
Textbox2 : Mot de passe
Textbox3 : Pseudo
Textbox4 : Email
Textbox5 : Captcha
NumericUpDown1 : augmenter de 1 le nom de compte ( ajoute +1 a chaque compte creer )
NumericUpDown2 : pareille que le 1 mais pour le pseudo
NumericUpDown3 : Choisir le nombre de caractère a générer
3) détaille du code
Sert Enregistrer le compte et quitter le programme après que le compte soit enregistré
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim name_file As String
name_file = TextBox1.Text 'variable qui dit que name_file = TextBox1.Text
Dim monwriter As New IO.StreamWriter(name_file & ".txt", True) ' ecrit le .txt avec name_file = TextBox1.Text = le texte qu'il y aura dans la txtbox
monwriter.Write(TextBox1.Text)
monwriter.Write(TextBox2.Text)
monwriter.Write(TextBox3.Text)
monwriter.Write(TextBox4.Text)' toutes ces lignes seront ecrit dans le fichier
monwriter.Close() 'fin de l'écriture
Dim message As String = ""
message = "Le compte a bien été créé" & vbCrLf & _
"Le Nom du compte est " & name_file
MsgBox(message, MsgBoxStyle.Information, "Compte enregistré avec succès")
Me.Close() 'ferme le prog
End Sub
Génrateur de caractère :
Dim charset As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" ' les caractère que le générateur va générer ^^"
Dim Rand As String = ""
Dim random As New Random
Public Function GenerateRand(ByVal lenRand As Integer) As String
For i As Integer = 0 To lenRand - 1
Rand += charset(random.Next(0, charset.Length))
Next
Return Rand
End Function
Private Sub generate_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button2.Click
Randomize()
Rand = Nothing
TextBox1.Text = GenerateRand(NumericUpDown1.Value)
Rand = Nothing
TextBox2.Text = GenerateRand(NumericUpDown1.Value)
Rand = Nothing
TextBox3.Text = GenerateRand(NumericUpDown1.Value)
Rand = Nothing
TextBox4.Text = GenerateRand(NumericUpDown1.Value) ' augmente le nombre de caratctère de 1
Rand = Nothing
TextBox5.Text = GenerateRand(NumericUpDown1.Value) & ("@hotmail.fr") ' ajoute le @hotmail.fr sur la txtbox 5
End Sub
Enrter les caractères sur le site (webbrowser)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Url = New Uri("https://secure.dofus.com/fr/creer-un-compte") ' adresse du webbrowser
hbwait(10000) ' temps d'attente pour eviter que le prog lance la complétation alors que la page n'a pas fini de charger
WebBrowser1.Document.GetElementById("userlogin").Focus() ' correspond a la txt box 1 du site dofus
hbwait(100)
SendKeys.Send(TextBox1.Text + NumericUpDown2.Value.ToString) ' ajoute 1 apres le nom du compte augmente de 1 à chaque fois
NumericUpDown2.Value = NumericUpDown2.Value + 1
hbwait(300)
WebBrowser1.Document.GetElementById("userpassword").Focus() ' la txtbox2 du site sa sera la même que la 3 car sa comme sa pas besoin de remettre le même mdp à la main
hbwait(100)
SendKeys.Send(TextBox2.Text)
hbwait(300)
WebBrowser1.Document.GetElementById("userpassconfirm").Focus()
hbwait(100)
SendKeys.Send(TextBox2.Text)
hbwait(300)
WebBrowser1.Document.GetElementById("usernickname").Focus()
hbwait(100)
SendKeys.Send(TextBox3.Text)
NumericUpDown1.Value = NumericUpDown1.Value + 1
hbwait(300)
WebBrowser1.Document.GetElementById("useremail").Focus()
hbwait(100)
SendKeys.Send(TextBox4.Text)
hbwait(300)
WebBrowser1.Document.GetElementById("step_1_sub").Focus()
hbwait(200)
WebBrowser1.Document.GetElementById("step_1_sub").InvokeMember("Click")
hbwait(2000)
Code final :
Cliquez pour révéler
Cliquez pour masquer
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim name_file As String
name_file = TextBox1.Text
Dim monwriter As New IO.StreamWriter(name_file & ".txt", True)
monwriter.Write(TextBox1.Text & writeln & TextBox2.Text)
monwriter.Write(TextBox2.Text)
monwriter.Write(TextBox3.Text)
monwriter.Write(TextBox4.Text)
monwriter.Close()
Dim message As String = ""
message = "Le compte a bien été créé" & vbCrLf & _
"Le Nom du compte est " & name_file
MsgBox(message, MsgBoxStyle.Information, "Compte enregistré avec succès")
Me.Close()
End Sub
Friend Sub hbwait(ByVal ms_to_wait As Long)
Dim endwait As Double
endwait = Environment.TickCount + ms_to_wait
While Environment.TickCount < endwait
System.Threading.Thread.Sleep(1)
Application.DoEvents()
End While
End Sub
Dim charset As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
Dim Rand As String = ""
Dim random As New Random
Public Function GenerateRand(ByVal lenRand As Integer) As String
For i As Integer = 0 To lenRand - 1
Rand += charset(random.Next(0, charset.Length))
Next
Return Rand
End Function
Private Sub generate_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button3.Click
Randomize()
Rand = Nothing
TextBox1.Text = GenerateRand(NumericUpDown3.Value)
Rand = Nothing
TextBox2.Text = GenerateRand(NumericUpDown3.Value)
Rand = Nothing
TextBox2.Text = GenerateRand(NumericUpDown3.Value)
Rand = Nothing
TextBox3.Text = GenerateRand(NumericUpDown3.Value)
Rand = Nothing
TextBox4.Text = GenerateRand(NumericUpDown3.Value) & ("@hotmail.fr")
End Sub
Private Sub NumericUpDown3_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown3.ValueChanged
End Sub
Public Function RandomString(ByVal CharList, ByVal Length)
Dim TmpRndStr As String
TmpRndStr = ""
While TmpRndStr.Length < Length
TmpRndStr = TmpRndStr & Mid(CharList, Rnd() * Len(CharList) + 1, 1)
End While '
Return TmpRndStr '
End Function
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Url = New Uri("https://secure.dofus.com/fr/creer-un-compte")
hbwait(10000)
WebBrowser1.Document.GetElementById("userlogin").Focus()
hbwait(100)
SendKeys.Send(TextBox1.Text + NumericUpDown2.Value.ToString)
NumericUpDown2.Value = NumericUpDown2.Value + 1
hbwait(300)
WebBrowser1.Document.GetElementById("userpassword").Focus()
hbwait(100)
SendKeys.Send(TextBox2.Text)
hbwait(300)
WebBrowser1.Document.GetElementById("userpassconfirm").Focus()
hbwait(100)
SendKeys.Send(TextBox2.Text)
hbwait(300)
WebBrowser1.Document.GetElementById("usernickname").Focus()
hbwait(100)
SendKeys.Send(TextBox3.Text)
NumericUpDown1.Value = NumericUpDown1.Value + 1
hbwait(300)
WebBrowser1.Document.GetElementById("useremail").Focus()
hbwait(100)
SendKeys.Send(TextBox4.Text)
hbwait(300)
WebBrowser1.Document.GetElementById("step_1_sub").Focus()
hbwait(200)
WebBrowser1.Document.GetElementById("step_1_sub").InvokeMember("Click")
hbwait(2000)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.Document.GetElementById("usercaptcha").Focus()
hbwait(100)
SendKeys.Send(TextBox5.Text)
hbwait(300)
WebBrowser1.Document.GetElementById("step_2_sub").Focus()
hbwait(200)
WebBrowser1.Document.GetElementById("step_2_sub").InvokeMember("Click")
hbwait(2000)
For Each ClientControl As HtmlElement In WebBrowser1.Document.Links
ListBox1.Items.Add(ClientControl.GetAttribute("href"))
Next
Dim deco As String = ListBox1.Items(5)
WebBrowser1.Url = New Uri(deco)
End Sub
End Class
Edit : Petite correction l'enregistrement sauter pas de ligne a chaque textbox dans le fichier txt
modifer
monwriter.Write(TextBox1.Text)
monwriter.Write(TextBox2.Text)
monwriter.Write(TextBox3.Text)
monwriter.Write(TextBox4.Text)' toutes ces lignes seront ecrit dans le fichier
par
monwriter.Write("nom de compte: " & TextBox1.Text & vbCrLf & "mot de pass: " & TextBox2.Text & vbCrLf & "pseudo: " & TextBox3.Text & vbCrLf & "email: " & TextBox4.Text)