• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: best approach?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: best approach?


  • Subject: Re: best approach?
  • From: Shane Stanley <email@hidden>
  • Date: Tue, 08 Dec 2015 14:55:26 +1100

On 8 Dec 2015, at 2:42 PM, 2551 <email@hidden> wrote:

Won’t that fail rather ungracefully if the app isn’t running when the script is executed (e.g. what if the app crashed and terminated just as the user executed the script)?

Yes, it would be better like this perhaps:

on forceQuitAppID:theID
set theApp to (current application's NSRunningApplication's runningApplicationsWithBundleIdentifier:theID)'s firstObject()
if theApp is not missing value then -- still running
set theURL to theApp's bundleURL()
theApp's forceTerminate()
delay 0.5
current application's NSWorkspace's sharedWorkspace()'s openURL:theURL
else -- it's already quit
delay 0.5
tell current application's NSWorkspace's sharedWorkspace()
set theURL to its URLForApplicationWithBundleIdentifier:theID
its openURL:theURL
end tell
end if
end forceQuitAppID:

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

References: 
 >best approach? (From: Dee Dee <email@hidden>)
 >Re: best approach? (From: Shane Stanley <email@hidden>)
 >Re: best approach? (From: 2551 <email@hidden>)

  • Prev by Date: Re: best approach?
  • Next by Date: Re: AS Library Question
  • Previous by thread: Re: best approach?
  • Next by thread: I made a nightmare
  • Index(es):
    • Date
    • Thread