[HELP] Hi - Bot help

Posts 16–18 of 18 · Page 2 of 2
Quote Originally Posted by Blubb1337 View Post
You choob prolly used me.checkf...rather than control.checkf..!
Nein.

Heil Hitler.
First of all I would like to say thank you all
Now, let me explain stuff xP :

Quote Originally Posted by Jason
It looks like you're using Erinador's tutorial on threading? I'll have to say, that tut is super confusing for someone beginning in threading as it goes across classes and implemented a seemingly useless thread that only sleeps.
Yes I am...

Quote Originally Posted by Jason
Basically, why are you even using a random thread on that sub?
To sleep the thread while the "Page"(its not a page, only a pop up javascrip ,or what ever) loads so I can select the world...

Quote Originally Posted by NextGen1
I think he was using the thread solely to sleep the application in hopes it would load the page.

Which is why I explained about document_completed.

(not sure though)
True... Thats it I simply want to sleep the thread so it finishes loading...
btw the Document_completed works perfecly when the webpages acctualy changes (like to send the attacks) but for the login I haven't managed to make it work (dunno if it even works)

@Blubbs1337
Well I'll try to use that.... Never tryed before...
Btw... Didn't you make a multithreading tuturial a very long time ago? like 6months/1 year ago? I think that I've seen it on MPGH a long time ago....



Finally,
Let me explain my problem better (with the codes and stuff so that you can understand my problem xP)....

This DOESN'T WORK:

Code:
Public Sub LogIn()
        WebBrowser1.Document.GetElementById("user").SetAttribute("value", "lalala")
        WebBrowser1.Document.GetElementById("password").SetAttribute("value", "lalala")
        WebBrowser1.Document.GetElementById("login_button").InvokeMember("click")
' >>>>NEED TO WAIT HERE<<<<
        Dim elementList As HtmlElementCollection
        Dim curElement As HtmlElement
        elementList = WebBrowser1.Document.GetElementsByTagName("a")
        For Each curElement In elementList

            If curElement.GetAttribute("innerText").Equals("Mundo 20") Then

                curElement.InvokeMember("click")

            End If
        Next
    End Sub
Because I need to wait for the world selection thing to load....


But this works:

Code:
 Public Sub LogIn()

        WebBrowser1.Document.GetElementById("user").SetAttribute("value", "lalala")
        WebBrowser1.Document.GetElementById("password").SetAttribute("value", "lalala")
        WebBrowser1.Document.GetElementById("login_button").InvokeMember("click")

    End Sub
    Public Sub LogIn2()
        Dim elementList As HtmlElementCollection
        Dim curElement As HtmlElement
        elementList = WebBrowser1.Document.GetElementsByTagName("a")
        For Each curElement In elementList

            If curElement.GetAttribute("innerText").Equals("Mundo 20") Then

                curElement.InvokeMember("click")

            End If

        Next
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        LogIn2()
        Timer2.Stop()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        LogIn()
Timer2.Start()
    End Sub
So my question is how do I make the second code without timers... (not so complicated...)

Should I use multithreading? What can I do?

Thank you
Of course it won't sleep properly, you're sleeping an external thread which has no relevance to the current code execution. It will start the new thread and then straight away do the next item on the agenda. The new thread might be sleeping, but seeing as your code is on the main thread, it will still be executed straight away. As NextGen said, handle the DocumentCompleted event instead. Will give far more accurate results.
Posts 16–18 of 18 · Page 2 of 2
This thread is closed for replies.

Tags for this Thread

None

Talk with us