← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #654441]: multiple screenshot analysis in a script

 

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

    Status: Open => Answered

Manfred Hampl proposed the following answer:
If you have limited number of images, you could use something like

while True:
  if exists(Pattern("image seen as of monday").targetOffset(-16,-58)):
      print('found 1st image')
  elif exists(Pattern("image seen as of tuesday").targetOffset(-16,-58)):
      print('found 2nd image')
  elif exists(Pattern("image seen as of wednesday").targetOffset(-16,-58)):
      print('found 3nd image')
  else:
      print('none of the images found')
      break # retry from the beginning
  hover(getLastMatch())
  #do the real action

With a varying list of images for checking, the case is a bit more complicated.
There are possibilities to loop through all files in a directory, and you would then have to use them in sequence in a exists() statement in a loop until you have found a match (or no match at all).
See python documentation for os.path.walk or os.walk (depending on your python version)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.