I use a function whose sole purpose is to return a reference to System
Events to avoid this problem:
import appscript as ap
def getSystemEvents():
try:
# ask System Events for processes to see if it's there
throwaway = ap.app('/System Events').processes
I have a long running server that uses appscript to send keystroke commands
to System Events.
It seems that System Events does not run constantly, or frequently dies.
Quite often, appscript seems to be in a state where it incorrectly thinks
System Events is running, and still sends commands to it,