Re: best approach?
Re: best approach?
- Subject: Re: best approach?
- From: Shane Stanley <email@hidden>
- Date: Tue, 08 Dec 2015 13:06:27 +1100
On 8 Dec 2015, at 12:31 PM, Dee Dee <email@hidden> wrote:
For example, if I have an applescript send a command to the app and the applescript times out (because the app has become unresponsive), is it possible to have applescript then test to see if the app is unresponsive and if so, to quit it, then restart the app?
Sure. You trap the timeout error in a try block, and then you have a choice of using do shell script and killall, or something like the following (10.9 and up, in a script library in 10.9):
use scripting additions use framework "Foundation" use framework "AppKit"
my forceQuitAppID:"com.apple.mail"
on forceQuitAppID:theID set theApp to (current application's NSRunningApplication's runningApplicationsWithBundleIdentifier:theID)'s firstObject() set theURL to theApp's bundleURL() theApp's forceTerminate() delay 0.5 current application's NSWorkspace's sharedWorkspace()'s openURL:theURL end forceQuitAppID:
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden