Naem 0 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 Share this post Link to post Share on other sites
Tvern 11 Posted December 3, 2010 Look at your code and consider what function you are checking @error for. Share this post Link to post Share on other sites
Naem 0 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 Share this post Link to post Share on other sites
JohnOne 1,603 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. Share this post Link to post Share on other sites