Hack Forums
[.NET] Need help coding a bot in VB2010! - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Need help coding a bot in VB2010! (/showthread.php?tid=4136983)

Pages: Pages 1 2


Need help coding a bot in VB2010! - Vipеr - Mar 26, 2014

Hey guys! I want to build a program similar to a "view bot". This bot is not for YouTube. I tried using text boxes but that requires to much time. This was the original code (timer 1 had an interval of 5 seconds and timer 2 an interval of 10 seconds):

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Navigate(TextBox1.Text)
Timer1.Start()
Timer2.Start()
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
WebBrowser1.Navigate(TextBox2.Text)
End Sub

Private Sub Timer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Timer2.Stop()
WebBrowser1.Navigate(TextBox3.Text)
End Sub


What code could I use that would go to the links in a rich text box, line after line every 5 seconds?


* - DBots - Mar 26, 2014

You could use the .Lines property in RichTextBox.

You could then get your URL with .Lines(0), .Lines(1), etc. on every timer tick.


* - Vipеr - Mar 26, 2014

what code could I use so that I don't have to manually retype .Lines(1) .Lines(2) .Lines(3)...
something like navigate to RichTextBox1 line 1 wait 5 sec then +1 (next line) everytime


* - Only3 - Mar 26, 2014

(Mar 26, 2014 08:57 PM)DBots Wrote:  You could use the .Lines property in RichTextBox.

You could then get your URL with .Lines(0), .Lines(1), etc. on every timer tick.

TextBox also have lines property 😊


* - Vipеr - Mar 26, 2014

I made a new form with a RichTextBox, a WebBrowser and a Button.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Navigate(RichTextBox1.Lines(1))
End Sub

In the RichTextBox I put:
www.google.com
www.yahoo.com

I try to run the program but instead of going to line 1 of the text it skips to the end. Can anyone help me?


* - StarZ - Mar 26, 2014

Make an array that holds the URL's (Not hard to load them from a *.txt) and use it that way. I would scold over the use of a webbrowser, however, I'm not exactly sober enough to judge whether it's permitted here.


* - BloodVulture - Mar 27, 2014

Do you want it to continuously loop through the links or just once each?


* - DBots - Mar 27, 2014

(Mar 26, 2014 10:39 PM)Only3 Wrote:  TextBox also have lines property 😊

(Mar 26, 2014 08:40 PM)ViperCoder Wrote:  What code could I use that would go to the links in a rich text box, line after line every 5 seconds?

Either or. Just trying to answer his question.


* - wizardwizard - Mar 27, 2014

This would work, however instead of every 5 seconds you may want to check if docuiment is completed.
Code
For x As Integer = 0 To 5
     WebBrowser1.Navigate(TextBox1.Lines(x))
     System.Threading.Thread.Sleep(5000)
Next



* - Vipеr - Mar 27, 2014

Basically what I want to do is have a RichTextBox with a bunch of links, for example:
www.google.com
www.yahoo.com
When I press a button I want the WebBrowser goes to the first link which is google.com, then the second link yahoo.com but between every website it waits 5 seconds. So it would be: webbrowser navigates to google.com, waits 5sec, navigate to yahoo.com, wait 5sec...
I don't want it to loop, just goes through the list once then it stop.


Doesn't the System.Threading.Sleep(5000) stop the entire program and not just the webbrowser? That would just do the same as skipping to the last link but with a 5sec delay after the button is pushed.


* - BloodVulture - Mar 28, 2014

(Mar 27, 2014 06:32 PM)ViperCoder Wrote:  Basically what I want to do is have a RichTextBox with a bunch of links, for example:
www.google.com
www.yahoo.com
When I press a button I want the WebBrowser goes to the first link which is google.com, then the second link yahoo.com but between every website it waits 5 seconds. So it would be: webbrowser navigates to google.com, waits 5sec, navigate to yahoo.com, wait 5sec...
I don't want it to loop, just goes through the list once then it stop.


Doesn't the System.Threading.Sleep(5000) stop the entire program and not just the webbrowser? That would just do the same as skipping to the last link but with a 5sec delay after the button is pushed.

Code
For i As integer = 0 To RichTextBox1.Lines.Length - 1
    WebBrowser1.navigate(RichTextBox1.Lines(i))
    Threading.thread.sleep(5000)
Next
Msgbox("done")

Typed on my phone


* - wizardwizard - Mar 28, 2014

(Mar 28, 2014 01:00 AM)BloodVulture Wrote:  
Code
For i As integer = 0 To RichTextBox1.Lines.Length - 1
    WebBrowser1.navigate(RichTextBox1.Lines(i))
    Threading.thread.sleep(5000)
Next
Msgbox("done")

Typed on my phone

Thats what I gave.

(Mar 27, 2014 06:32 PM)ViperCoder Wrote:  Basically what I want to do is have a RichTextBox with a bunch of links, for example:
www.google.com
www.yahoo.com
When I press a button I want the WebBrowser goes to the first link which is google.com, then the second link yahoo.com but between every website it waits 5 seconds. So it would be: webbrowser navigates to google.com, waits 5sec, navigate to yahoo.com, wait 5sec...
I don't want it to loop, just goes through the list once then it stop.


Doesn't the System.Threading.Sleep(5000) stop the entire program and not just the webbrowser? That would just do the same as skipping to the last link but with a 5sec delay after the button is pushed.

Well thats why you should use a document completed instead of a wait. AndAlso what I gave naiivgates all of them. Are you sure you are starting the count at 0?


* - BloodVulture - Mar 28, 2014

(Mar 28, 2014 07:12 AM)dmratcliffe Wrote:  Thats what I gave.

Well thats why you should use a document completed instead of a wait. AndAlso what I gave naiivgates all of them. Are you sure you are starting the count at 0?

You gave a set number, 5. I did it so it works with any number of lines.


* - Vipеr - Mar 28, 2014

Hmm. I used the code you gave me and did the following:
New Form, added RichTextBox, Button and a WebBrowser.
Went into the codding for the button and put:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i As Integer = 0 To RichTextBox1.Lines.Length - 1
WebBrowser1.Navigate(RichTextBox1.Lines(i))
Threading.Thread.Sleep(5000)
Next
MsgBox("done")
End Sub

When I ran the program and pressed the button, the program just waited then displayed the last link. I was wondering if you could give me a code where it would show each page in the webbrowser. So far it's all white, a msgbox pops up saying done then the last link shows. Thx, cheers!


* - wizardwizard - Mar 28, 2014

(Mar 28, 2014 10:54 AM)ViperCoder Wrote:  Hmm. I used the code you gave me and did the following:
New Form, added RichTextBox, Button and a WebBrowser.
Went into the codding for the button and put:

PHP Code

<?php 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      
For i As Integer = 0 To RichTextBox1.Lines.Length - 1
      WebBrowser1
.Navigate(RichTextBox1.Lines(i))
      
Threading.Thread.Sleep(5000)
      
Next
      MsgBox
("done")
    
End Sub 

When I ran the program and pressed the button, the program just waited then displayed the last link. I was wondering if you could give me a code where it would show each page in the webbrowser. So far it's all white, a msgbox pops up saying done then the last link shows. Thx, cheers!
(please use PHP or code tags)

This is because you are sending way to much to the web browser before it is done loading.

You will need to check if the web browser is done loading.