• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

VB.NET BLOGS POSTER.NNED HELP!

HI All.I Have Did The blogs poster.
On my PC its Work Perferctly,But on Other it doesnt Work Correctly.
The Code IS here:
Imports System.IO
Imports System.Text
Imports System.Net
Public Class Form1
    Dim A As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("http://passport.yandex.ru/passport?mode=passport")
        Me.WebBrowser1.ScriptErrorsSuppressed = True
    End Sub
    '# start
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()
        RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "starting Work!"
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        Try
            If WebBrowser1.DocumentText.Contains("¿¿¿¿¿¿¿¿¿¿¿¿ ¿¿¿¿¿¿") Then
                RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "login sucessful!"
                Timer1.Stop()
                Timer2.Start()
            End If
        Catch ex As Exception
        End Try
    End Sub
    'connection,insert the data
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If WebBrowser1.ReadyState <> WebBrowserReadyState.Loaded Then
            Try
                RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "conecting!"

                Dim user As String
                Dim pass As String
                Dim mails As String
                mails = ListBox1.Items(0)
                Dim pos() As String = mails.Split(":")
                user = pos(0)
                pass = pos(1)
                RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "entering the Dates!" & user & ":" & pass
                WebBrowser1.Document.All("b-domik-username11").InnerText = user
                WebBrowser1.Document.All("b-domik-password11").InnerText = pass
                Dim doc = WebBrowser1.Document
                RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "login!"
                doc.GetElementsByTagName("INPUT")(3).InvokeMember("click")
                Label3.Text = (ListBox2.Items.Count & " ")
            Catch ex As Exception
            End Try
        End If
    End Sub
    '¿¿¿¿¿¿¿ ¿¿ ¿¿¿¿
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Try
            WebBrowser1.Navigate(ListBox2.Items.Item(0).ToString)
            RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "Go to Blog: " & ListBox2.Items(0) & "!"
            Timer2.Stop()
            Dim ts As TimeSpan
            Dim targetTime As DateTime = DateTime.Now.AddSeconds(NumericUpDown2.Value)
            Do
                ts = targetTime.Subtract(DateTime.Now)
                Application.DoEvents() ' keep app responsive
                System.Threading.Thread.Sleep(50) ' reduce CPU usage
            Loop While ts.TotalSeconds > 0
        Catch ex As Exception
        End Try
            Timer2.Stop()
        If WebBrowser1.ReadyState <> WebBrowserReadyState.Loaded Then
            Timer4.Start()
        End If
    End Sub
    'Load Blogs
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim Mails As String
        Dim LineIn As String
        Dim oRead As System.IO.StreamReader
        If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
            Mails = OpenFileDialog1.FileName
            oRead = IO.File.OpenText(Mails)
            While oRead.Peek <> -1
                LineIn = oRead.ReadLine()
                ListBox2.Items.Add(LineIn)
            End While
            Label3.Text = (ListBox2.Items.Count & " ")
            If ListBox2.Items.Count = 0 Then
                Label3.Text = "0"
            Else

            End If
        End If

    End Sub
    'stop
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Timer1.Stop()
        Timer2.Stop()
        Timer4.Stop()
        Timer5.Stop()
        Timer6.Stop()
    End Sub
    'searching "¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿ ¿ ¿¿¿¿"
    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
        If WebBrowser1.ReadyState <> WebBrowserReadyState.Loaded Then
            Try
                WebBrowser1.Document.GetElementById("rec-comment").InvokeMember("click")

                Timer4.Stop()
                Timer5.Start()
            Catch ex As Exception
                RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "Error: " & ListBox2.Items(0) & " The text Wasnt Posted"
                Timer4.Stop()
                ListBox2.Items.RemoveAt(0)
                Timer2.Start()
                Label3.Text = (ListBox2.Items.Count & " ")
                Application.DoEvents()
            End Try
        End If
    End Sub
    'Post
    Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
        Try
            RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "Writing Message!"
            WebBrowser1.Document.Window.DomWindow.execscript("tinyMCE.activeEditor.setContent('<span>" + RichTextBox1.Text + "</span>')", "JavaScript")

            Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
            For Each webpageelement As HtmlElement In allelements

                If webpageelement.GetAttribute("value") = " OK " Then

                    webpageelement.InvokeMember("click")

                End If

            Next
            RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "¿¿¿¿: " & ListBox2.Items(0) & " Posted!"
            Label10.Text = (Label10.Text) + 1
            If Int(Label10.Text / NumericUpDown1.Value) = Label10.Text / NumericUpDown1.Value Then ListBox1.Items.RemoveAt(0) : Label1.Text = (Label1.Text - 1) : WebBrowser1.Navigate("http://passport.yandex.ru/passport?mode=logout") : Timer6.Start()
            Timer5.Stop()
            ListBox2.Items.RemoveAt(0)
            Label3.Text = (ListBox2.Items.Count & " ")
            Timer2.Start()
        Catch ex As Exception
            RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "Error: " & ListBox2.Items(0) & " Not Posted"
            Timer5.Stop()
            ListBox2.Items.RemoveAt(0)
            Label3.Text = (ListBox2.Items.Count & " ")
            Timer2.Start()
            Application.DoEvents()
        End Try
    End Sub
    'Clear Listbox 1
    Private Sub Button5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        ListBox1.Items.Clear()
    End Sub
    'Save LOG
    Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Dim w As New IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Log.txt")
        w.WriteLine(RichTextBox2.Text())
        w.Close()
    End Sub
    'Clear Listbox 2
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        ListBox2.Items.Clear()
    End Sub
    'Stop Parsing
    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Timer3.Stop()
        For I As Integer = 0 To ListBox2.Items.Count - 1
            For T As Integer = I + 1 To ListBox2.Items.Count - 1
                If T < ListBox2.Items.Count Then
                    If ListBox2.Items(I) = ListBox2.Items(T) Then
                        ListBox2.Items.RemoveAt(T)
                        T -= 1
                    End If
                End If
            Next
        Next
        ListBox2.Items.Clear()
    End Sub
    'Go to login form
    Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick
        If Timer6.Enabled = True Then
            Timer2.Enabled = False
        End If
        WebBrowser1.Navigate("http://passport.yandex.ru/passport?mode=passport")
        Dim ts As TimeSpan
        Dim targetTime As DateTime = DateTime.Now.AddSeconds(4)
        Do
            ts = targetTime.Subtract(DateTime.Now)
            Application.DoEvents() ' keep app responsive
            System.Threading.Thread.Sleep(50) ' reduce CPU usage
        Loop While ts.TotalSeconds > 0

        Timer1.Start()
        Timer6.Stop()
    End Sub
End Class

Open in new window

What can i do to do the posting to fast,maybe with 1 timer and working on all pc?
Thanks
0
Replica178
Asked:
Replica178
  • 2
1 Solution
 
CodeCruiserCommented:
>But on Other it doesnt Work Correctly
In what way?

0
 
Replica178Author Commented:
on others computers.
0
 
Replica178Author Commented:
(((((((((((
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now