brad25 Posted September 1, 2012 Share Posted September 1, 2012 Ok having a hard time figuring this out im wanting my program to sleep as long as it finds this color. So its gonna be in a loop to keep checking for a change. $coord = PixelSearch( 170, 89, 1100, 700, 0xd02929) and when it no longer see's the color to MsgBox(4096, "Test", "color not found any longer", 10) any help would be great and i cant use pixelgetcolor as the cords of the color will change thanks. Link to comment Share on other sites More sharing options...
JohnOne Posted September 1, 2012 Share Posted September 1, 2012 (edited) Do you know what a loop is? EDIT: And how to check a return value of a function call? Edited September 1, 2012 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...
brad25 Posted September 1, 2012 Author Share Posted September 1, 2012 (edited) Do you know what a loop is? EDIT: And how to check a return value of a function call? Thanks for the fast reply my question is how do i make it sleep until this code is no longer true$coord = PixelSearch( 170, 89, 1100, 700, 0xd02929) Edited September 1, 2012 by brad25 Link to comment Share on other sites More sharing options...
JohnOne Posted September 1, 2012 Share Posted September 1, 2012 PixelSearch(...) is a function call, it returns certain values if it is successful and sets @error if it is not. So testing those values in your loop, will tell you if the function was successful of not. And a conditional statement (If...Else...EndIf) can act (or not) your messagebox. Have a quick look at Pixelsearch in the helpfile, and try it. 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...
brad25 Posted September 1, 2012 Author Share Posted September 1, 2012 PixelSearch(...) is a function call, it returns certain values if it is successfuland sets @error if it is not.So testing those values in your loop, will tell you if the function was successfulof not.And a conditional statement (If...Else...EndIf) can act (or not) your messagebox.Have a quick look at Pixelsearch in the helpfile, and try it.ok i can get the pixelsearch part to work just getting the conditional statement to msgbox the color has not been found im struggling with . Maybe an example? Link to comment Share on other sites More sharing options...
brad25 Posted September 1, 2012 Author Share Posted September 1, 2012 anyone? Link to comment Share on other sites More sharing options...
JohnOne Posted September 1, 2012 Share Posted September 1, 2012 Can you post your code? 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...
brad25 Posted September 2, 2012 Author Share Posted September 2, 2012 Can you post your code? while 1 $coord = PixelSearch( 170, 89, 1100, 700, 0xd02929) $yoyoy = PixelSearch( 170, 89, 1100, 700, 0xc72626) $yovyoy = PixelSearch( 170, 89, 1100, 700, 0xc82626) If Not @error Then ;if the colors above are not found i want it to do this below Else MouseClick("right") sleep(5000) MouseClick("left") sleep(1500) EndIf WEnd Link to comment Share on other sites More sharing options...
JohnOne Posted September 2, 2012 Share Posted September 2, 2012 You are trying to find multiple colours but only checking if the last one is found So you need to test each one, and if any one of them is not found, then continue the loop from the beginning while 1 $coord = PixelSearch( 170, 89, 1100, 700, 0xd02929) If @error Then _DoStuff() ContinueLoop EndIf $yoyoy = PixelSearch( 170, 89, 1100, 700, 0xc72626) If @error Then _DoStuff() ContinueLoop EndIf $yovyoy = PixelSearch( 170, 89, 1100, 700, 0xc82626) If @error Then _DoStuff() ContinueLoop EndIf ;Code to do something if the colours are found WEnd ;if the colors above are not found i want it to do this below Func _DoStuff() MouseClick("right") sleep(5000) MouseClick("left") sleep(1500) EndFunc 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...
JohnOne Posted September 2, 2012 Share Posted September 2, 2012 And add a Sleep(100) into the loop else you will batter your CPU 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...
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