if command for images

Asked by Mona

I am using 2 images.

image 1 , image 2

if image 1 exists, it should popup some text

same with other image
else, popup some other text.

My command is like below
:

if exists("Busy-1.PNG",2):
    popup("Busy")
elif exists("available_1.PNG",2):
    popup("Available")
else :
popup ("Meeting")

but every time it is popping up Busy.

Please suggest

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Mona
Solved:
Last query:
Last reply:
Revision history for this message
masuo (masuo-ohara) said :
#1

How do you change the exists() to not exists()

if not exists("Busy-1.PNG",2):
    if not exists("available_1.PNG",2):
    else:
        popup("Available")
else:
    popup("Busy")

Revision history for this message
Mona (barbiegirls-mona) said :
#2

Got the following error masuo

[error] Error message: SyntaxError: ("mismatched input 'else' expecting INDENT"

Revision history for this message
Mona (barbiegirls-mona) said :
#3

But worked this way.

if not exists("Busy1.PNG",2):
    if not exists("available_2-2.PNG",2):
        if not exists("meeting.PNG",2):
            popup("Offline")
        else:
            popup("Meeting")
    else:
     popup("Available")
else:
    popup("Busy")

Cant we get the desired ouput with if exists ??

Revision history for this message
Mona (barbiegirls-mona) said :
#4

But the output for the last command is also popping the first "popup" i.e, Away.

It is not working.

Please suggest

Revision history for this message
masuo (masuo-ohara) said :
#5

You have to find out, what Sikuli finds.

For exsample:

if exists("Busy1.PNG"):
    getLastMatch().highlight(3)

if exists("available_2-2.PNG"):
    getLastMatch().highlight(3)

if exists("meeting.PNG"):
    getLastMatch().highlight(3)

Similar question was found.
https://answers.launchpad.net/sikuli/+question/207797

It was not a problem of exists() or not exists() , sorry.

Revision history for this message
Mona (barbiegirls-mona) said :
#6

Thanks. the issue is with score i.e, similarity.

Revision history for this message
Mona (barbiegirls-mona) said :
#7

Thanks. the issue is with score i.e, similarity.