Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

But 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?

Posted

@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.

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...