LuisGA Posted October 31, 2009 Share Posted October 31, 2009 Hello. I have this little script, in which i use pixelsearch to search for a pixel that is changing constantly. What im trying to do is to click on a certain spot of the screen when $greycoord[0] (coordinate X) is at the X coordinate 478 but i got this error. C:\user\?????\?????\?????\test.au3 (30) : ==> Subscript used with non-Array variable.: if $greycoord[0] = 478 Then if $greycoord^ ERROR Here is the script so far. HotKeySet("{ESC}", "Terminate") Func Terminate() Exit 0 EndFunc While (1) $greycoord = PixelSearch( 295, 476, 785, 490, 0xB6B6B6, 0) if $greycoord[0] = 478 Then Sleep (1500) MouseClick("left", 240, 484, 10, 0) EndIf WEnd What can i do?. Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 31, 2009 Share Posted October 31, 2009 Add some error handling. When PixeSearch() fails to find the color, it sets @error and doesn't return an array. Try this: If IsArray($greycoord) And ($greycoord[0] = 478) Then Or this: If (@error = 0) And ($greycoord[0] = 478) Then Since the logic is tested left-to-right (outside of parens), when $greycoord is not an array (or error is set) the "And" is already false so no attempt is made to access $greycoord[0]. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
LuisGA Posted November 1, 2009 Author Share Posted November 1, 2009 Add some error handling. When PixeSearch() fails to find the color, it sets @error and doesn't return an array. Try this: If IsArray($greycoord) And ($greycoord[0] = 478) Then Or this: If (@error = 0) And ($greycoord[0] = 478) Then Since the logic is tested left-to-right (outside of parens), when $greycoord is not an array (or error is set) the "And" is already false so no attempt is made to access $greycoord[0]. I understand now thanks for the help, my script works now that i understand a little more about it. 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