Sign in to follow this  
Followers 0
Forge

Skipping Pixelsearch and loop.

15 posts in this topic

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

Why do it directly goto 'Send' ?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Problem is that it never do Ctrl-L when the color appear, first I noticed I had wrong coords but I fixed but still nothing.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Edited by Forge

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

255 doesn't work anyhow.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

* 1 - It's appearing.

* 2 - It stays for about 20 secs so not a problem.

* 3 - Nope

Share this post


Link to post
Share on other sites

Also, is there a way too check if something enters the screen in form of text?

Share this post


Link to post
Share on other sites

Posted Image

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

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0