Re: Cocoa scripting: targeting an app via its bundle identifier
Re: Cocoa scripting: targeting an app via its bundle identifier
- Subject: Re: Cocoa scripting: targeting an app via its bundle identifier
- From: Andy Lee <email@hidden>
- Date: Sun, 26 Jun 2011 08:09:23 -0400
On Jun 26, 2011, at 6:09 AM, Bill Cheeseman wrote:
>
> On Jun 25, 2011, at 7:52 PM, Andy Lee wrote:
>
>> get application id "com.yourcompany.TrivialScriptable"
>> set myApp to result
>> tell myApp
>
>
> It has been true since the beginning of time (1993) that you cannot 'tell' a variable but must instead 'tell' the application, at least in most cases. It's one of the reasons why us old timers think of AppleScript as a "trial and error" language. You have to learn many of the rules by doing, not by reading the manual.
I gathered as much from the "Scope of This Book" chapter of Matt Neuburg's book.
> I wrote this particular issue up at length many years ago in two old articles that are still available on The AppleScript Sourcebook at <http://macscripter.net/viewtopic.php?id=24570> and <http://macscripter.net/viewtopic.php?id=24569>. Some of what I wrote then is no longer completely true, thanks to the ongoing evolution of AppleScript.
I almost stumbled across the "double-tell" technique. In one of my iterations I used the bundle id to activate the app, then used the name in a separate tell block to send my custom command. It didn't occur to me to nest the tells.
The "double-tell" reminds me of casting an Objective-C variable to get rid of a compiler warning, when you know that the method you're calling will be found at runtime. The "compiler warning" in AppleScript is when you save or run the script and a command name doesn't turn bold.
Thanks, Bill!
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden