← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #214233]: not exists doesn't do anything

 

Question #214233 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/214233

    Status: Open => Solved

Nicole Demers confirmed that the question is solved:
For future readers, here's a recap of the comments.

The error was because the search was not precise enough;
exists("HEWLETTPACKA.png") was producing a false positive.

To fix the issue search within a region and use a higher matching index.

It's also helpful to use rgn.getLastMatch() to help speed up processing.
This makes it so that instead of finding the image again it just uses
the regions last match.

Lastly, it was bad practice to use separate images. It's not as optimal
to retake the image every time -- not only does it take up extra space
in memory, but it might not have the same find results when there are
several options available.

Solution:
clarifyLogo = find("FilaE.png")
rgn = clarifyLogo.right().below()  #If you know how big the screen will be it's better to extend by a pixel amount and further refine the search area. Unfortunately this one will be run on many computers and will be different each time.

i = 0
if(not rgn.exists(Pattern("HEWLETTPACKA-2.png").similar(0.95))): #Increased similarity to hone results
    click("1352827765773-1.png")
    while (i < 10):
        for j in range(0, 28):
            type(Key.DOWN)
        wait(1)
        if(rgn.exists(Pattern("HEWLETTPACKA-2.png").similar(0.95))): #Same image and similarity as last find to streamline results
            break
        i = i + 1
    #if loop finished then no HP orders were found, exit program
    if(i == 10):
        exit()

doubleClick(rgn.getLastMatch())


Thank you RaiMan for the solution!

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.