Skip to content

Instantly share code, notes, and snippets.

@RKursatV
Created June 25, 2018 15:45
Show Gist options
  • Save RKursatV/a9ae4d778aa9aa32c18c8b1187985c29 to your computer and use it in GitHub Desktop.
Save RKursatV/a9ae4d778aa9aa32c18c8b1187985c29 to your computer and use it in GitHub Desktop.
ch4nger
Public Class Form1
Dim basla = 0
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'baslat butonu
basla = 1
WebBrowser1.Navigate("https://register.metu.edu.tr")
Timer2.Start()
End Sub
Public Sub verigir()
If InStr(1, WebBrowser1.Document.Body.OuterText, "CENG") = 0 Then
MsgBox("Program sadece CENG öğrencilerinin kullanımına açıktır! Program sonlandırılıyor...", MsgBoxStyle.Critical, "Mission Accomplished!")
Me.Close()
End If
For Each ele As HtmlElement In WebBrowser1.Document.All
If ele.GetAttribute("value").ToLower = TextBox6.Text & "|" & TextBox3.Text & "|1".ToLower Then
ele.InvokeMember("click")
End If
Next
Dim htmlElement As HtmlElement = WebBrowser1.Document.GetElementById("textChangeCourseSection")
If htmlElement IsNot Nothing Then
htmlElement.SetAttribute("value", TextBox1.Text)
End If
Dim PageElements As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
For Each CurElement As HtmlElement In PageElements
If CurElement.Name = "submitChangeSection" Then
gl = 0
CurElement.InvokeMember("click")
End If
Next
End Sub
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If basla = 1 Then
If InStr(1, WebBrowser1.Document.Body.OuterText, "expired") Then
RichTextBox1.Text += "Session expired" + vbCrLf
WebBrowser1.Navigate("https://register.metu.edu.tr")
ElseIf InStr(1, WebBrowser1.Document.Body.OuterText, "Login") Then
RichTextBox1.Text += "Logging in" + vbCrLf
Dim htmlElement As HtmlElement = WebBrowser1.Document.GetElementById("textUserCode")
If htmlElement IsNot Nothing Then
htmlElement.SetAttribute("value", TextBox4.Text)
End If
Dim htmlElementx As HtmlElement = WebBrowser1.Document.GetElementById("textPassword")
If htmlElementx IsNot Nothing Then
htmlElementx.SetAttribute("value", TextBox5.Text)
End If
For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
If Element.OuterHtml.Contains("submitLogin") Then
Element.InvokeMember("click")
End If
Next
ElseIf InStr(1, WebBrowser1.Document.Body.OuterText, "full") Then
verigir()
RichTextBox1.Text += "Capacity is full" + vbCrLf
ElseIf InStr(1, WebBrowser1.Document.Body.OuterText, "Select") Then
MsgBox("Section Başarıyla Değiştirildi! Program sonlandırılıyor...", MsgBoxStyle.Information, "Mission Accomplished!")
Me.Close()
ElseIf WebBrowser1.Document.Title = "Registration" Then
verigir()
Else
RichTextBox1.Text += "What the hell is this?" + vbCrLf
WebBrowser1.Navigate("https://register.metu.edu.tr")
End If
End If
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
WebBrowser1.Navigate("https://register.metu.edu.tr")
RichTextBox1.Text = ""
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click ' Durdur butonu
Timer2.Stop()
basla = 0
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment