← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #578456]: [1.1.1] macOS: App.focus: Occasionally: Where is osascript

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
ok, this is much easier:

def If_Choose_App_Appeared():
    shitHappened = false
    setRect(458, 187, 823, 657)
    while exists(Pattern("1490794202722.png").similar(0.90)): # Image with Choose Application Header
        print "Running Check_App_Focus - Found Choose Application"
        if exists("1490794220568.png"): # Cancel Button
            print "Check_App_Focus - Found Cancel"
            click(getLastMatch())
            shitHappened = true
    return shitHappened

def App_Focus_Failing():
    max = 3
    while True:
        App.focus("Tynon")
        if not If_Choose_App_Appeared():
            break # focus should have worked, otherwise try again
        max -= 1
        if max < 0: # to avoid endless loop if workaround does not work
            print "no chance - exiting"
            exit(1)

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