Using findall and clickall without getting an error if image doesn't exit
<p>I can't figure out what I'm doing wrong. The code works great as long as there is an image displayed for the <code>findall</code>, but if <code>x</code> doesn't appear, then I get an error: </p>

<p><code>[error] FindFailed ( can not find P(1474201252795.png) S: 0.99 in R[0,0 1920x1080]@S(0) )</code></p>

<p>Not quite sure how to fix this.</p>

<pre><code>running = True

def runHotkey(event):
    global running
    running = False

Env.addHotkey(Key.F1, KeyModifier.CTRL, runHotkey)

while exists("1474199877323.png")and running:

    click("1474138615993.png")
    click("1474138629993.png")
    wait(5)
    if exists("1474201633804.png"):
        for x in findAll(Pattern("1474201252795.png").exact()):
          click(x)
          click("1474201809505.png")       
    else:
        click("1474201689791.png")
    wait(5)
</code></pre>

<p>As per documentation <code>findAll</code> throws an Exception on failed search. (<a href="https://github.com/sikuli/sikuli/blob/develop/sikuli-script/src/main/java/org/sikuli/script/Region.java#L434" rel="nofollow">docs</a>). Try to use <code>hasNext()</code> method along with context manager, e.g.</p>

<pre><code>with findAll(Pattern(...)) as mm:
    while mm.hasNext():
        x = mm.next()
        // process x
</code></pre>

python jython sikuli