I have an applescript that runs automatically and relies on the application "Contacts" to be running. Occasionally, it fails when the "Contacts" process mysteriously disappears from the activity monitor, although the dock still shows it as running.
The following will NOT work:
- Applescript "tell application "Contacts" to activate
- Applescript "tell application "Contacts' to quit (both respond with "application not running)
- Applescript "do shell script killall launchserviced" followed by "killall dock" executes ok but doesn't solve the problem
Only solution is to MANUALLY quit "Contacts" from the dock and then reactivate it but that solution is not satisfactory because it requires a manual intervention. Any ideas as to a) why the error happens and b) how can I cater for the error by quiting "Contacts" from applescript ?
Any ideas will be appreciated
In response to bmike's comment;
Running OS X 10.10.5 and here is the relevant section of the applescript
set todaysdate to (current date) as text
*tell application "System Events"
try set myprocessid to (get id of process "Contacts") on error number errorno display dialog errorno if errorno is equal to -1728 then -- process not found try tell application "System Events" to run application "Contacts" on error number errorno if errorno = -600 then display dialog errorno & todaysdate as text end if end try do shell script "/bin/sleep 3" --and allow enough time for the app to activate end if end try
This section attempts to activate "Contacts" if it finds the process is not running (error -1728). It then attempts to run the app but it always errors out with -600 (app not running). A simple applescript to quit the app also errors out with -600.
So, if the process is missing, the app cannot be activated and quit does not work either.
Thanks for your comments