1

I am trying to create a applescript that when I double click on it, the code activates an (or multiple) application/s from inside it. e.g. I just click on this script and it opens Photo booth and COD.

  • What app is "COD"? – user3439894 Aug 16 '18 at 12:41
3

You can use path to resource to get the pathname of the .app file that's in an App's Resource folder, and then use Finder to open the apps, e.g.:

set appPath1 to path to resource "AppName1.app"
set appPath2 to path to resource "AppName2.app"

tell application "Finder"
    open appPath1
    open appPath2
end tell

Note: This method is for use from a AppleScript App's script that is run upon the AppleScript App being opened. If this is not what you're lookin for, then I misunderstood your question. If I did misunderstand, would you please clarify your question.

1

If you prefer to run the code within your script editing application as well as the application on its own, this solution always works for me.

set theApp to (path to me as text) & "Contents:Resources:YOUR APP.app"

tell application "Finder" to open theApp
  • Sorry to hear that you've never been successful using the default AppleScript builtin path to resource, why do you think that is? It has always worked for me. – user3439894 Aug 16 '18 at 16:53
  • I just retested it again. In script debugger when I run the app after it has been compiled and saved, I continue to get the error. However, when I launch the application on its own... I do not get the error. Quite odd – wch1zpink Aug 16 '18 at 17:02
  • No that's not odd as it's only suppose to work at the AppleScript App's running script level, which is how it returns the proper path of the resource when the AppleScript App itself is opened. – user3439894 Aug 16 '18 at 17:06
  • I understand what you're saying but if nothing else… it's a little inconvenient having to actually launch the app to see if everything works within the code. I guess in this situation it's not a huge deal but in other circumstances, if the code were to contain several hundred lines, debugging the code and troubleshooting errors becomes a nightmare. Don't you think? – wch1zpink Aug 16 '18 at 17:12
  • IMO using path to resource is a more proper way as Apple designed it to be used that way, but whatever works for you it's your choice. As far as debugging, when writing code one should always write/use appropriate error handlers, which if written well should limit the debugging process, if not point directly to the problem itself. The bottom line is, what I posted is a bare minimum example and the onus is always upon the user to write/use appropriate error handlers in their code. [The other option is, do not write bad code. :) ] – user3439894 Aug 16 '18 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .