tiago Posted April 25, 2011 Share Posted April 25, 2011 Hi I wanna know if theres a command line to get back to another line in the top, something like: "if @error then go to line 2" Thanks, and sorry for my bad inglish, im from Brazil. Link to comment Share on other sites More sharing options...
JohnOne Posted April 25, 2011 Share Posted April 25, 2011 Yes You make the code between line 2 and @error a function. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tiago Posted April 25, 2011 Author Share Posted April 25, 2011 sorry i dont understand i mean, if i got a error on line 30, theres a way to back to line 2 and try everything again? Link to comment Share on other sites More sharing options...
monoscout999 Posted April 25, 2011 Share Posted April 25, 2011 there are many ways to do that... maybe do until loop ex do ...... ..... until NOT @error then the part in the middle will be reproduced until the function don´t do error... i suggest use small pieces of scipts and do functions with them... a question what function sets the error? Link to comment Share on other sites More sharing options...
JohnOne Posted April 25, 2011 Share Posted April 25, 2011 (edited) With Autoit, and most evolved languages, you must thing a little diiferently that what you are. Stop thinking about line numbers and begin thinking about what the code on those lines do. When you have a few lines of code that perfoms as a function or task, you would write it as such. Take this code, you can have it run from anywhere in your script, regardless of what line its on, you dont use Goto 2 you simple call the function. Func _Read() $sValue = IniRead("MyIni.ini","SECTION","Key","Fail") Return $sValue EndFunc EDIT: If you are having trouble understanding it, then the best thing to do is present some code where you think you would need a goto line, and either myself or someone else will show you how it ought to be done. To clarify, there is no goto keyword in autoit3 Edited April 25, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tiago Posted April 26, 2011 Author Share Posted April 26, 2011 (edited) allright friends im trying others methods something like that sleep (5000) $coord = PixelSearch( 0, 800, 1400, 170, 0xc5c2c5, 0 ) if true then MouseClick( "right", $coord[0], $coord[1], 2, 1 ) MouseClick("left", $Coord[0]+20, $Coord[1]+30, 8, 1) endif if $coord false Then Send("{F1") endif but its error when pixelsearch fails how can i send F1 when pixelsearch fails? Edited April 26, 2011 by tiago Link to comment Share on other sites More sharing options...
tiago Posted April 26, 2011 Author Share Posted April 26, 2011 this one is more simple sleep (5000) $F1 = Send("{F1}") while 1 $coord = PixelSearch( 0, 800, 1400, 170, 0xc5c2c5, 0 ) if @error then return $F1 MouseClick ( "right", $coord[0], $coord[1], 2, 1 ) MouseClick ("left", $Coord[0]+20, $Coord[1]+30, 8, 1) wend how can i return? Link to comment Share on other sites More sharing options...
JohnOne Posted April 26, 2011 Share Posted April 26, 2011 Something like this. Sleep(5000) $F1 = Send("{F1}") While 1 _Search(); keep searching until it finds your pixel If Not @error Then ExitLoop; if the pixel is found and the clicks are performed loop will end. Sleep(100) WEnd Func _Search() $coord = PixelSearch(0, 800, 1400, 170, 0xc5c2c5, 0) If @error Then Return SetError(1);if it erroes it returns to the while loop MouseClick("right", $coord[0], $coord[1], 2, 1) MouseClick("left", $coord[0] + 20, $coord[1] + 30, 8, 1) EndFunc ;==>_Search AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
tiago Posted April 26, 2011 Author Share Posted April 26, 2011 (edited) Something like this. Sleep(5000) $F1 = Send("{F1}") While 1 _Search(); keep searching until it finds your pixel If Not @error Then ExitLoop; if the pixel is found and the clicks are performed loop will end. Sleep(100) WEnd Func _Search() $coord = PixelSearch(0, 800, 1400, 170, 0xc5c2c5, 0) If @error Then Return SetError(1);if it erroes it returns to the while loop MouseClick("right", $coord[0], $coord[1], 2, 1) MouseClick("left", $coord[0] + 20, $coord[1] + 30, 8, 1) EndFunc ;==>_Search thanks JohnOne it works, but now how i loop everything? i wanna keep this running EDIT: i found, its just erase "If Not @error Then ExitLoop; if the pixel is found and the clicks are performed loop will end." i need a hotkey comand to stop the loop any idea? Edited April 27, 2011 by tiago Link to comment Share on other sites More sharing options...
sahsanu Posted April 27, 2011 Share Posted April 27, 2011 i need a hotkey comand to stop the loopany idea?Yes, take a look to HotKeySet. In the example you have the answer. Link to comment Share on other sites More sharing options...
tiago Posted April 27, 2011 Author Share Posted April 27, 2011 thank you and if i want to try find another pixel? i try this: Func _Search() $coord = PixelSearch(0, 800, 1400, 170, 0xc5c2c5, 0) and $coord2 = PixelSearch(0, 800, 1400, 170, 0xff66bf, 0) i try "and" and(lol) "or" but it doesnt work and i do this MouseClick("right", $coord[0], $coord[1], 2, 1) MouseClick("left", $coord[0] + 30, $coord[1] + 50, 8, 1) if $coord2 true then MouseClick("left", $coord2[0], $coord2[1], 1, 1) endif where is my fault? Link to comment Share on other sites More sharing options...
monoscout999 Posted April 27, 2011 Share Posted April 27, 2011 (edited) thank you and if i want to try find another pixel? i try this: Func _Search() $coord = PixelSearch(0, 800, 1400, 170, 0xc5c2c5, 0) and $coord2 = PixelSearch(0, 800, 1400, 170, 0xff66bf, 0) i try "and" and(lol) "or" but it doesnt work and i do this MouseClick("right", $coord[0], $coord[1], 2, 1) MouseClick("left", $coord[0] + 30, $coord[1] + 50, 8, 1) if $coord2 true then MouseClick("left", $coord2[0], $coord2[1], 1, 1) endif where is my fault? first for the better understand between all i suggest use the code format for the code.. second you need to think well what do you want the program do and explain to us... third you need to understand that you have many errors.. you need to start to try to understand the help..(it help a lot) fourt return doesn´t mean "return to line blabla...." it means what value do you want the function return.. a value of a handle, a variable, etc fifht... ...I think that this what you want XD Func _Search() $coord = PixelSearch(0, 800, 1400, 170, 0xc5c2c5) ; I remove the 0 at the end.. is optional If Not @error Then ; You have to give an answer to an error if you don´t... ; ...do that the program will crash... MouseClick("right", $coord[0], $coord[1], 2, 1) ;sleep(????) ; maybe you need to put some time to delay the other click MouseClick("left", $coord[0] + 30, $coord[1] + 50, 8, 1) EndIf $coord2 = PixelSearch(0, 800, 1400, 170, 0xff66bf) If Not @error Then MouseClick("left", $coord2[0], $coord2[1], 1, 1) EndIf EndFunc ;==>_Search Or maybe i´m wrong it will be helpful if you tell us for what is this script Edited April 27, 2011 by monoscout999 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