Jump to content

Skipping Pixelsearch and loop.


Recommended Posts

Why do it directly goto 'Send' ?

Because @error only reports the success or failure of the last command used. As soon as you tell it to Sleep(), it will change @error. You probably want the pixel search function inside your loop, and below the Sleep() so that the proper error value is being tested.

Edit: You don't want to use the return value to test in your loop. Just use While @error instead.

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

WinWaitActive("Tibia")

$coord = PixelSearch( 1300, 240, 240, 450, 0x884B40, 10)

While @error

sleep (200)

PixelSearch( 1300, 240, 240, 450, 0x884B40, 10)

WEnd

send ("^{L}")

Doesn't work aswell

Link to comment
Share on other sites

WinWaitActive("Tibia")

While @error

sleep (200)

$coord = PixelSearch( 1300, 240, 240, 450, 0x884B40, 10)

WEnd

send ("^{L}")

Still doesn't work :D

That time @error was 0 because the the WinWaitActive function worked fine. Try this instead:

WinWaitActive("Tibia")
Do
  sleep (200)
  $coord = PixelSearch( 1300, 240, 240, 450, 0x884B40, 10)
Until NOT @error
send ("^{L}")

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

The helpfile mentions that this is pretty time consuming, so maybe the pixel is moving in such a way that it avoids detection, or doesn't appear long enough to be detected. If this could be the case, try shortening your sleep, or taking a smaller region so that it takes less time to scan the region for the specific pixel color.

Edit: You could also try increasing the variation to allow for more flexibility in the color, if that might also be an issue.

Edited by pekster

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

Funny, I tried 50000 in variation and still no reaction.

That might not be a good thing to try: the helpfile says only a max of 255 is allowed. I'm not sure, but sometimes if values are out of range it will default to the default, which is 0 in this case.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

Well, if your script is getting stuck in that loop, the pixel is doing 1 of 3 things:

  • Not appearing
  • Appearing and vanishing before the function detects it, or
  • Staying on the screen, but moving in such a way that it avoids detection (see note below)
Note: #3 could occur if the pixel moves from an undetected region of the screen to an already detected region (where the function has already scanned that iteration of the loop) and thus avoid detection.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

When someone enters "battle". Can you scan off the text?

It's called OCR (stands for <something> Character Recognition) but it's very hard to do. If the window background is always the same color, how about taking a PixelCheckSum (see the helpfile) of that region, and comparing that with what it is when you want to know if it says "battle" or not. Be sure you're using the latest beta of AutoIt (version 3.0.102, the later builds are usually better.)

As for your pixel problem, I'm out of ideas. I did test this function myself (Using a very similar Do-Until loop like I posted) and it worked fine. It stayed in that loop until I opened a window that had a pixel I defined (a white one) in the region I gave to the PixelSearch function. Just make sure that your region is correct, and the color is correct.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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