Serajin Posted January 23, 2008 Share Posted January 23, 2008 Hello, I am trying to create an infinite loop to search a pixel for a color if it changes. The way i am doing this is like so. While @error == 1 $newCoord = PixelSearch($coord[0] - 1, $coord[1]-3, $coord[0], $coord[1]-5, 0x008629) WEnd I am trying to use the original coodinates to create the secondary as an offset set of coordinates. However whenever i try to compile this i get the following error. C:\Users\\Desktop\MouseMove.au3 (23) : ==> Subscript used with non-Array variable.: $newCoord = PixelSearch($coord[0] - 1, $coord[1]-3, $coord[0], $coord[1]-5, 0x008629) $newCoord = PixelSearch($coord^ ERROR Here is my whole code. $coord = PixelSearch ( 590 , 572 , 689, 587 , 0xFF8A00 ) ;PixelSearch ( left, top, right, bottom, color [, shade-variation] [, step]] ) If Not @error Then ;MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) MouseMove($coord[0], $coord[1], 0) EndIf If Not @error Then MouseMove($coord[0] - 1, $coord[1] - 4, 0) EndIf While @error == 1 $newCoord = PixelSearch($coord[0] - 1, $coord[1]-3, $coord[0], $coord[1]-5, 0x008629) WEnd All help appreciated Thanks Serajin Link to comment Share on other sites More sharing options...
stampy Posted January 23, 2008 Share Posted January 23, 2008 Sounds like the first pixel search is erroring out and not creating an array. You are not trapping for that. Need to find out why it's not working and add the trap to control Link to comment Share on other sites More sharing options...
Serajin Posted January 23, 2008 Author Share Posted January 23, 2008 Sounds like the first pixel search is erroring out and not creating an array. You are not trapping for that. Need to find out why it's not working and add the trap to controlBut thats just the thing. The first pixel search DOES work, because i have it moving my mouse to where its located. And it is successfully going there. The only time its causing an error is when im taking the array and forcing the number in the 0 position of the array and the 1 position into a second array. Maybe i have to create duplicate variables for the X and Y coordinates to successfully get it? Link to comment Share on other sites More sharing options...
weaponx Posted January 23, 2008 Share Posted January 23, 2008 @ERROR is only valid immediately after a function call. If you call another function then @ERROR gets reset. You need to store the first @ERROR into a temp variable if you want to reuse it. Link to comment Share on other sites More sharing options...
Serajin Posted January 23, 2008 Author Share Posted January 23, 2008 Thank you all for your help. I got it working with using some other way. However it is not possible due to server lag on the side of the program that I am attempting to do this with. It is always 1 or 2 pixels out, with a 1/3 chance of getting it right. So it will not work. Thank you all for your help Serajin 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