← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #215858]: Monitor app for 'Not Responding'; if not restart

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
a quick and dirty solution (from Mac to Mac ;-)

# use this image to check the running state
isRunning = "1354537857024.png"
# use this image to select the entry
toQuit = "1354537969267.png"
sikuli = "1354538350389.png"
second = False
while True:
    type(Key.ESC, KeyModifier.ALT+KeyModifier.CMD)
    tasks = App.focusedWindow()
    tasks.highlight(1)
    if second: break
    # asure a non-disturbing selection
    if tasks.exists(sikuli): click(tasks.getLastMatch())
    wait(1)
    if not tasks.exists(isRunning, 0):
        print "app seems to hang"
        break
    else:
        print "app seems to work normally"
    type("w", KeyModifier.CMD) 
    wait(5)
    # second = True # uncomment for testing with normal running app

# to her we get only if app seems to hang
# so we try to kill it
if tasks.exists(sikuli): click(tasks.getLastMatch())
            
if not tasks.exists(toQuit):
    type("w", KeyModifier.CMD)
    print "app does not seem to run at all"
    exit(1)
forceQuit = "1354538467661.png"
tasks.click(forceQuit)
type(Key.TAB)
type(" ")
wait(1)
tasks.waitVanish(toQuit, 10)
type("w", KeyModifier.CMD)
print ("app should have ended")

to see the used images: 
https://dl.dropbox.com/u/42895525/forcequit.sikuli.zip

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