← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #190442]: Dict/Vdict and screenshots with names

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
The Vdict construct was originally designed as some image database, that
you could lookup with an image (e.g. icons, photos or similar stuff).
This means, you have a probe and ask the VDict, wether it is contained.

In your case it seems, that you want to check, wether one or more of different images are visible on the screen.
And it seems, that you do not want a case structure, but a dictionary instead, that is used to check, what is on the screen.

If I guess right, forget VDict, just use a normal dictionary, where the
image names (file names) are the keys.

SandCastleVD = {}
SandCastleVD[mini_sand_p0051_question] = "10"
SandCastleVD[mini_sand_p0052_question] = "20"

def runMiniSandCastles():
    for img in SandCastleVD:
        if exists(img, 0):
            type(SandCastleVD[img])
            break

runMiniSandCastles()

--- comment on exists(img, 0)
the 0 as second parameter tells Sikuli to search only once and not wait the standard 3 seconds. This speeds things up.
More speed could be gained by narrowing the search region to not being the whole screen.

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