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

Re: Saving an AppleScript that targets my own application


  • Subject: Re: Saving an AppleScript that targets my own application
  • From: Daniel Jalkut <email@hidden>
  • Date: Sun, 8 Jan 2006 10:33:26 -0500

Hi Derrick - we need to get to the bottom of this problem in your particular case. Suffice to say that this is not a problem across the board.

I use NDApplecript in FastScripts, where I run all manner of scripts including scripts that are targeting FastScripts itself.

That being said, I don't *compile* the scripts in FastScripts - is that what you're doing with your example script? As a quick test, what happens if you paste and save the script from Script Editor, and then load it as a compiled script from disk in your application?

Also, is there anything funky about your application, like you forgot to give it a Bundle ID or something?

Daniel

On Jan 8, 2006, at 4:30 AM, Derrick Bass wrote:

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:
sweater.com


This email sent to email@hidden

_______________________________________________ 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: Derrick Bass <email@hidden>
References: 
 >Saving an AppleScript that targets my own application (From: Derrick Bass <email@hidden>)

  • Prev by Date: Re: Sort array of filenames
  • Next by Date: Newbie cuestion on document based app and menus
  • Previous by thread: Saving an AppleScript that targets my own application
  • Next by thread: Re: Saving an AppleScript that targets my own application
  • Index(es):
    • Date
    • Thread