Jump to content
IAMK

And/Or Issue? [CLOSED]

Recommended Posts

IAMK

I observed 2 misbehaviours. Is the issue my understanding or AutoIT itself?

My script is supposed to sleep until 1 of 2 desired colours is seen.

While(PixelGetColor(260, 975) <> 39922 Or PixelGetColor(260, 975) <> 41714)
    Sleep(500)
WEnd

The above should sleep if colour1 is true and colour2 is false? Mine didn't sleep. (I guess Or moves left->right until first pass is seen)

While(PixelGetColor(260, 975) <> 39922 And PixelGetColor(260, 975) <> 41714)
    Sleep(500)
WEnd

The above should sleep if both colours are false? Mine didn't sleep if colour2 was true. (Note this is the code I currently use but don't understand why it's failing).

Edited by IAMK

Share this post


Link to post
Share on other sites
Subz

Can't tell you what the limitations of While Expressions are, but it appears that it only likes a single expression, for example:

While PixelGetColor(260, 975) <> 39922
    Sleep(500)
WEnd

However you can use multiple expressions within the loop for example:

While 1
    If PixelGetColor(260, 975) = 39922 Or PixelGetColor(260, 975) = 41714 Then ExitLoop
    Sleep(500)
WEnd

 

Share this post


Link to post
Share on other sites
IAMK

This issue is resolved. The issue was not the logic, but the file being used.

Share this post


Link to post
Share on other sites
Subz

Your first snippet didn't work for me, unless I used the If statement, I'm not really sure "the file being used" is referring to.

Share this post


Link to post
Share on other sites
IAMK

@Subz, I was editing the script on machine1, but testing the exe on machine2, of which the IP is different by 1 number...

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

×