Alright so I've got a program that plays a game for me and moves around the rooms of the city. Sometimes if the server lags it loses track and keeps running. Since it reads where to go from a listbox it just continues on and wastes time.
The reason for all the checks of images is the number of images varies depending on the page. Is there an easier way to find the image I want? (I grab the image since its name=the room number I'm in. then I search the listbox for that and tell the program that's where it is.Code:
Private Sub wbNav_DocumentComplete(ByVal pDisp As Object, URL As Variant)
On Error Resume Next
If (WebPageContains("go to a room not next to it.") = True) Then
Call errorDetected
errorYes = True
ElseIf (URL = GAME+"/world.php" And errorYes = True) Then
Call errorFixer
End If
lblCurrent.Caption = (Replace(URL, GAME, ""))
End Sub
'''''
'Error Fixing and Detection!
'''''
Private Function errorDetected()
tmrInterval.Enabled = False
wbNav.Navigate (GAME+"/world.php")
End Function
Private Function errorFixer()
On Error Resume Next
Dim imagesrc As String, karaOke As Integer, argh As String
argh = wbNav.Document.images(3).src
If (WebPageContains("/images/world/map/")) Then
imagesrc = (wbNav.Document.images(3).src)
If (StrComp(argh, "/images/world/crewadv.jpg", vbTextCompare) = 0) Then
imagesrc = (wbNav.Document.images(4).src)
ElseIf (StrComp(argh, "/images/world/mobtalk.jpg", vbTextCompare) = 0) Then
imagesrc = (wbNav.Document.images(4).src)
End If
If (StrComp(wbNav.Document.images(4).src, "/images/world/crewadv.jpg", vbTextCompare) = 0) Then
imagesrc = (wbNav.Document.images(5).src)
ElseIf (StrComp(wbNav.Document.images(4).src, "/images/world/mobtalk.jpg", vbTextCompare) = 0) Then
imagesrc = (wbNav.Document.images(5).src)
End If
imagesrc = Replace(imagesrc, GAME +"/world/map/", "/world.php?room=")
imagesrc = Replace(imagesrc, ".png", "")
For karaOke = 0 To lstRoutine.ListCount
If (StrComp(imagesrc, lstRoutine.List(karaOke)) = 0) Then
pickle = karaOke
karaOke = lstRoutine.ListCount + 21
End If
Next karaOke
End If
errorYes = False
tmrInterval.Enabled = True
End Function
