Skip to content

Instantly share code, notes, and snippets.

@possan
Last active December 17, 2017 18:34
Show Gist options
  • Save possan/047f2f8ada8e8a5fce8414ea00e19539 to your computer and use it in GitHub Desktop.
Save possan/047f2f8ada8e8a5fce8414ea00e19539 to your computer and use it in GitHub Desktop.
AppleScript to restart computer if Resolume stopped responding
tell application "Activity Monitor" to run
tell application "System Events" to tell process "Activity Monitor"
-- log window
-- print window 1
set num to 0
-- tell radio button 1 of radio group 1 of group 1 of toolbar 1 of window 1 to click --Using the CPU View
tell outline 1 of scroll area 1 of window 1 -- working with the list
-- look for processes with "Not Responding" in the title
set filteredrows to (rows whose value of first static text contains "Resolume" and value of first static text contains "Not Responding") -- Looking for Not responding process
repeat with aProcess in filteredrows
set pid to value of text field 5 of aProcess -- For each non responding process retrieve the PID
set x to value of first static text in aProcess
log "Found \"" & x & "\" with PID " & pid
set num to num + 1
end repeat
end tell
if num > 1 then
log "We have unresponsive processes, we should restart..."
tell application "Finder"
restart
end tell
end if
return num
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment