• 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
Saving an AppleScript that targets my own application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Saving an AppleScript that targets my own application


  • Subject: Saving an AppleScript that targets my own application
  • From: Derrick Bass <email@hidden>
  • Date: Sun, 8 Jan 2006 03:30:57 -0600

I'd like to save an AppleScript that targets my own application. Let's say, for example,
tell application "MyApplication"
activate
end tell


But I'm running into problems. I've tried both NDAppleScriptObject and the NSAppleScript category someone posted a few years back:
<http://lists.apple.com/archives/Cocoa-dev/2003/Nov/msg01693.html>


Both are suffering from the same problem: the resulting script doesn't target my application, but targets whatever application loads the script. So if I load the saved script in Script Editor, then it changes to
tell application "Script Editor"
activate
end tell


I noticed that Script Editor has the same problem if you write scripts that are supposed to target script editor (e.g., the same script run from the iTunes scripts menu apparently does nothing).

Is there some simple solution to this, or have I just run into an inherent limitation in AppleScript?

For a convoluted solution, I tried having my program process the script via the osacompile command-line app. But I discovered another annoying problem: although osacompile works just fine when my application is not running, if the app is running, then it sends Apple Events to it. So the naive approach of just launching an NSTask and waiting for it to finish doesn't work, because I get a deadlock (until the Apple Event times out and osacompile fails). So, any suggestions for how make that approach work?

Is there some other solution to my problem?

Thanks in advance.

Derrick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Saving an AppleScript that targets my own application
      • From: Daniel Jalkut <email@hidden>
  • Prev by Date: Re: is this string styled?
  • Next by Date: Sort array of filenames
  • Previous by thread: NSSplitView not resizing evenly
  • Next by thread: Re: Saving an AppleScript that targets my own application
  • Index(es):
    • Date
    • Thread