Code:
Public Function buyitem(captchaurl, price, itemurl)
Dim capimage As Bitmap = w.GrabPic(captchaurl, w.LastPage)
Dim ocr As New Point
ocr = docap(capimage)
strhtml = w.PostWrapper("http://www.neopets.com/haggle.phtml", "current_offer=" & price & "&x=" & ocr.X & "&y=" & ocr.Y, itemurl)
If strhtml.Contains("I accept your") = True Then
'Item bought
Return True
Else
Return False
End If
End Function
Public Function neologin(ByVal user As String, ByVal pass As String)
Dim strhtml As String
strhtml = w.GetWrapper("http://neopets.com/", "")
strhtml = w.PostWrapper("http://www.neopets.com/login.phtml?destination=%252Findex.phtml", "username=" & user & "&password=" & pass, "http://www.neopets.com/login.phtml")
If InStr(strhtml, "Location: /index.phtml") Then
Return True
Else
Return False
End If
End Function
Private Sub cmdneo_Click(sender As Object, e As EventArgs) Handles cmdneo.Click
If String.IsNullOrEmpty(txtneop.Text) Or String.IsNullOrEmpty(txtneop.Text) Then
MsgBox("Username or Password empty")
Else
If neologin(txtneou.Text, txtneop.Text) = True Then
MsgBox("Logged into neo")
cmdstart.Enabled = True
lblstatus.Text = "Status: Logged in"
Else
MsgBox("Failed to login")
End If
End If
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
'Stuffs
Do Until stopit = True
strhtml = w.GetWrapper("http://www.neopets.com/objects.phtml?type=shop&obj_type=21")
If strhtml.Contains("Enter your Neopets login information") Then
neologin(txtneou.Text, txtneop.Text)
End If
strhtml = w.GetWrapper("http://www.neopets.com/objects.phtml?type=shop&obj_type=21")
temp1 = GetBetweenAll(strhtml, "<BR></A><B>", "</B><BR>")
temp2 = GetBetweenAll(Replace(strhtml, ",", ""), "Cost: ", " NP")
temp3 = GetBetweenAll(strhtml, "this.href='haggle.phtml?ob'+'j_info_id=", "';if (!")
SetLabelText_ThreadSafe(lblbuy, "Searching shop...")
For x = 0 To lstsearch.Items.Count - 1
For y = 0 To temp1.Count - 1
If LCase(temp1.Item(y)) = LCase(lstsearch.Items(x)) Then
Setaddlist_ThreadSafe(lstlog, "Found " & temp1.Item(y))
start_time = Now
strhtml = w.GetWrapper("http://www.neopets.com/haggle.phtml?obj_info_id=" & temp3.Item(y), w.LastPage)
cap = "http://www.neopets.com/captcha_show.phtml?_x_pwned=" & GetBetween(strhtml, "/captcha_show.phtml?_x_pwned=", """")
intpause = GetRandom(Convert.ToInt32(pausemin.Text), Convert.ToInt32(pausemax.Text))
Setaddlist_ThreadSafe(lstlog, "Waiting " & intpause & " ms")
System.Threading.Thread.Sleep(intpause)
If buyitem(cap, temp2.Item(y), "http://www.neopets.com/haggle.phtml?obj_info_id=" & temp3.Item(y)) = True Then
stop_time = Now
elapsed_time = stop_time.Subtract(start_time)
Setaddlist_ThreadSafe(lstlog, "(" & Now.ToShortTimeString() & ") Bought " & temp1.Item(y))
Setaddlist_ThreadSafe(lstlog, "(" & Now.ToShortTimeString() & ") Took " & elapsed_time.TotalMilliseconds.ToString("0") & " ms")
Else
stop_time = Now
elapsed_time = stop_time.Subtract(start_time)
Setaddlist_ThreadSafe(lstlog, "(" & Now.ToShortTimeString() & ") Missed " & temp1.Item(y))
Setaddlist_ThreadSafe(lstlog, "(" & Now.ToShortTimeString() & ") Took " & elapsed_time.TotalMilliseconds.ToString("0") & " ms")
End If
End If
Next
Next
intref = GetRandom(Convert.ToInt32(refmin.Text), Convert.ToInt32(refmax.Text))
SetLabelText_ThreadSafe(lblbuy, "Pausing " & intref & " ms")
System.Threading.Thread.Sleep(intref)
Loop
SetLabelText_ThreadSafe(lblbuy, "Idle")
End Sub
Most likely not the most efficient code, but gets 950 - 1100 millisecond buys for me. First real program Ive made in like 2+ years.