Naem Posted December 3, 2010 Share Posted December 3, 2010 So a small part of my code keeps bugging if the pixel color isn't found, and I cant figure out why. Hopefully someone can help (I'm not very experienced) Func _FindColor () $Coords = PixelSearch(0, 0, @DesktopWidth - 1, @DesktopHeight - 1, 0xFF9632) Sleep(Random(700,1000)) If Not @error Then MouseClick('Left', $Coords[0]+50, $Coords[1]+110, 1, 0) EndIf Sleep(Random(700, 1000)) EndFunc This is the error message: C:\Users\Jason\Desktop\Show of the month bot.au3 (79) : ==> Subscript used with non-Array variable.: MouseClick('Left', $Coords[0]+50, $Coords[1]+110, 1, 0) MouseClick('Left', $Coords^ ERROR So the error is in the line that should never occur if the pixel color is not found - but it seems to run it anyway? I'm guessing that its a very obvious mistake, and I'm just blind. But this has been puzzling me for a good few hours now and driving me nuts. Any help appreciated, Naem Link to comment Share on other sites More sharing options...
Tvern Posted December 3, 2010 Share Posted December 3, 2010 Look at your code and consider what function you are checking @error for. Link to comment Share on other sites More sharing options...
Naem Posted December 3, 2010 Author Share Posted December 3, 2010 (edited) Its checking @error for the pixelsearch function. Apparently @error gets set to 1 if the color isn't found, but I've tried a wide variety of different attempts to avoid this error with no success. Attemps such as: If Not @error = 1 Then MouseClick('Left', $Coords[0]+50, $Coords[1]+110, 1, 0) EndIf Or If @error <> 1 Then MouseClick('Left', $Coords[0]+50, $Coords[1]+110, 1, 0) EndIf For some reason it will always run the "MouseClick" function, and find that theres no Array since the pixelsearch function didn't find anything. Edited December 3, 2010 by Naem Link to comment Share on other sites More sharing options...
JohnOne Posted December 3, 2010 Share Posted December 3, 2010 No, @error checks the previous function, which in the case of your script, is Sleep() 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