[HELP] Hi - Bot help
First of all I would like to say thank you all 
Now, let me explain stuff xP :
Originally Posted by Jason
Yes I am...
Originally Posted by Jason
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...
Originally Posted by NextGen1
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:
Because I need to wait for the world selection thing to load....
But this works:
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

Now, let me explain stuff xP :
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
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
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.
This thread is closed for replies.

