ecstatic Posted April 16, 2009 Share Posted April 16, 2009 (edited) Hey guys, semi new to autoit coding a bot in it. Heres my problemo. expandcollapse popupFunc Pindle() $Message = "OK, lets go kill pindle" Chat() Sleep(2000) Send($TeleportKey) Sleep(400) MouseMove(463, 88) MouseDown("right") MouseUp("right") Sleep(400) MouseMove(732, 156) MouseDown("right") MouseUp("right") Sleep(400) MouseMove(700, 186) MouseDown("right") MouseUp("right") Sleep(400) MouseMove(571, 173) MouseDown("right") MouseUp("right") Sleep(200) MouseMove(490, 250) MouseDown("right") MouseUp("right") If $Class = "Light Sorc" Then Send($SorcMain) Sleep(100) Do $MonsterFind = PixelSearch( 148, 34, 800, 291, $monsters ) If Not @error Then MouseClick("right", $monsterfind[0], $Monsterfind[1]) EndIf Until @error <> 0 $PindleKilled = $PindleKilled + 1 EndGame() EndIf If $Class = "Hammerdin" Then MouseClick("Right", 709, 173) Sleep(100) Send($ConcentrationKey) Send("{ShiftDown}") Do $MonsterFind = PixelSearch( 148, 34, 800, 291, $monsters ) If Not @error Then MouseDown("Left") Sleep(2500) MouseUp("Left") EndIf Until @error <> 0 $PindleKilled = $PindleKilled + 1 EndGame() EndIf EndFunc;==>Pindle OK, so it teleports to the monster, then starts finding the monsters and kills them My problem is, once it is done killing them and it is supposed to Function Endgame, Instead, the script exits and my guy sits there a like a dunce and dies. Heres some more etc code. IDK if u cant have 3x functions or something.. Sorry for the semi-bad english. expandcollapse popupFunc EndGame() Send("{Esc}") Sleep(500) Send("{Up}") Sleep(500) Send("{Enter}") Sleep(500) FileWriteLine($File, " We had a successful run" & @HOUR & ":" & @MIN & " - " & @MDAY & "/" & @LF) $GamesCompleted = $GamesCompleted + 1 Stats() CreateGame() EndFunc;==>EndGame Func CreateGame() $Message = "were creating a game now!" Chat() Stats() ;Credits go to Rijn for random string generation. MouseClick("left", 640, 485) Sleep($ClickDelay) $GameLength = Random(10, 15) $PassLength = Random(10, 15) For $x2 = 0 To $GameLength $Random = Random(97, 122) Send(Chr($Random)) Next Sleep($KeyDelay) Send("{TAB}") Sleep($KeyDelay) For $x3 = 0 To $PassLength $Random = Random(97, 122) Send(Chr($Random)) Next Sleep($KeyDelay) Send("{ENTER}") Sleep($KeyDelay) $GamesMade = $GamesMade + 1 Stats() FileWriteLine($File, "Made Game: " & @HOUR & ":" & @MIN & "." & @MDAY & "/" & @MON & "/" & @YEAR & @LF) Sleep(3000) CheckIngameact1() EndFunc;==>CreateGame ESC UP ENTER just gets from the menu to exited. CreateGame() isnt really an issue due to that it cannot get to EndGame() So wuts the problem gurus! Edited April 16, 2009 by ecstatic Link to comment Share on other sites More sharing options...
Nahuel Posted April 16, 2009 Share Posted April 16, 2009 (edited) Your problem could be here: Do $MonsterFind = PixelSearch( 148, 34, 800, 291, $monsters ) If Not @error Then MouseClick("right", $monsterfind[0], $Monsterfind[1]) EndIf Until @error <> 0 You see, @error's value is set back to 0 when calling a function. MouseClick is the one resetting @error, since it's unlikely it fails. So I suggest you replace that part with: $error=0 Do $MonsterFind = PixelSearch( 148, 34, 800, 291, $monsters ) $error=@error If Not $error Then MouseClick("right", $monsterfind[0], $Monsterfind[1]) EndIf Until $error <> 0 Try if that works. Edited April 16, 2009 by Nahuel Link to comment Share on other sites More sharing options...
qazwsx Posted April 16, 2009 Share Posted April 16, 2009 or While 1 $MonsterFind = PixelSearch( 148, 34, 800, 291, $monsters ) If @error Then exitloop MouseClick("right", $monsterfind[0], $Monsterfind[1]) Wend Link to comment Share on other sites More sharing options...
ecstatic Posted April 16, 2009 Author Share Posted April 16, 2009 (edited) Your problem could be here: Do $MonsterFind = PixelSearch( 148, 34, 800, 291, $monsters ) If Not @error Then MouseClick("right", $monsterfind[0], $Monsterfind[1]) EndIf Until @error <> 0 You see, @error's value is set back to 0 when calling a function. MouseClick is the one resetting @error, since it's unlikely it fails. So I suggest you replace that part with: $error=0 Do $MonsterFind = PixelSearch( 148, 34, 800, 291, $monsters ) $error=@error If Not $error Then MouseClick("right", $monsterfind[0], $Monsterfind[1]) EndIf Until $error <> 0 Try if that works. Sorry, it still exited early (((((( or While 1 $MonsterFind = PixelSearch( 148, 34, 800, 291, $monsters ) If @error Then exitloop MouseClick("right", $monsterfind[0], $Monsterfind[1]) WendGrr that dindt work ethir Edited April 16, 2009 by ecstatic Link to comment Share on other sites More sharing options...
qazwsx Posted April 16, 2009 Share Posted April 16, 2009 that was a replacement for his posted code. Is Autoit giving an error? Could i see the section of code where you are calling these functions? Is it completing the first function for sure? Link to comment Share on other sites More sharing options...
qazwsx Posted April 16, 2009 Share Posted April 16, 2009 put in some console writes and see where the script is crashing. Link to comment Share on other sites More sharing options...
ecstatic Posted April 16, 2009 Author Share Posted April 16, 2009 k Link to comment Share on other sites More sharing options...
ecstatic Posted April 16, 2009 Author Share Posted April 16, 2009 (edited) put in some console writes and see where the script is crashing.It is failing hereFunc EndGame() FileWriteLine($File, " We are trying to end game" & @HOUR & ":" & @MIN & " - " & @MDAY & "/" & @LF)Send("{Esc}")Sleep(500)Send("{Up}")Sleep(500)Send("{Enter}") Sleep(500) FileWriteLine($File, " We had a sucessful run" & @HOUR & ":" & @MIN & " - " & @MDAY & "/" & @LF) $GamesCompleted = $GamesCompleted + 1 Stats() CreateGame()EndFunc ;==>EndGameBut that line of code is mandatory Edited April 16, 2009 by ecstatic Link to comment Share on other sites More sharing options...
qazwsx Posted April 16, 2009 Share Posted April 16, 2009 does it fail after the same line of code? Or are u saying it is failing after the file write? Link to comment Share on other sites More sharing options...
ecstatic Posted April 16, 2009 Author Share Posted April 16, 2009 does it fail after the same line of code? Or are u saying it is failing after the file write?Failing after the file write but before the 2nd one.So inbetween the ESC UP ENTER Link to comment Share on other sites More sharing options...
ecstatic Posted April 16, 2009 Author Share Posted April 16, 2009 (edited) Heres what i did ;Send("{Esc}") ;Sleep(500) ;Send("{Up}") ;Sleep(500) Send("{Enter}") That worked! But i need ESC UP ENTER, its manditory Then i did Send("{Esc}") ;Sleep(500) ;Send("{Up}") ;Sleep(500) Send("{Enter}") And it didnt work. Is there an alternative to ESC that will still do Escape Edit: Even if i take it out of the function it doesnt work. Edited April 16, 2009 by ecstatic Link to comment Share on other sites More sharing options...
ecstatic Posted April 16, 2009 Author Share Posted April 16, 2009 FIXED! Figured out i had a hotkeyset to ESC Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now