exists(Pattern) finds something, but findall(Pattern) doesn't

Asked by David Scheele

Hi there,

strange problem. I'm strying to make an auto deleter for a manager program. It should find menu icons, right click them and then select delete. Sometimes the icons are not there but I would catch that with a simple "if exists(icon)", followed by a findAll algorithm clicking every icon. the code looks something like this:

    def deleteAllNodes(self):
        r = self.returnMenuColumn() #returns a region over the whole menu
        for icon in OEIconList:
            rPattern = Pattern(icon).exact() #Yes I tried with 0.7 and up, no change
            if r.exists(rPattern): #This sometimes works
                rFind = r.findAll(rPattern) #But then this doesn't which makes no sense

So for some reason the same pattern is found differently by exists and findAll.

Anyone have an explanation for this?

Thanks in advance!

Best,
David

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

version?

Revision history for this message
David Scheele (david-scheele2) said :
#2

Its 2015-04-07_01:00nightly

I solved my problem by going:

        r = self.returnMenuColumn()
        for icon in OEIconList:
            rPattern = Pattern(icon).exact()
            matches = r.findAll(rPattern) if r.exists(rPattern, 0) else ()

which gives me correct matches.

But the problem still previals. It's a weird occurence

Revision history for this message
RaiMan (raimund-hocke) said :
#3

Hääääh????

what is the difference?

just checked with this - works:

r = selectRegion()
img = "icon.png"
pImg = Pattern(img).exact()
if r.exists(pImg, 0):
  r.hover()
  matches = r.findAll(pImg)
  listMatches = list(r.findAll(pImg))

for m in listMatches:
  print m

while matches.hasNext():
  print matches.next()

Can you help with this problem?

Provide an answer of your own, or ask David Scheele for more information if necessary.

To post a message you must log in.