Last active
December 17, 2017 18:34
-
-
Save possan/047f2f8ada8e8a5fce8414ea00e19539 to your computer and use it in GitHub Desktop.
AppleScript to restart computer if Resolume stopped responding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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