Hi Andy.
It seems that the indirection confuses AppleScript, and it doesn't know which
dictionary to use. Is there a reason you don't use the following more simple
code?
tell application id "com.yourcompany.TrivialScriptable"
That works better in my testing.
-Jeff
On Jun 25, 2011, at 6:52 PM, Andy Lee wrote:
> This has been bedeviling me all day. As an AppleScript novice I suspect -- I
> *hope* -- I'm missing something trivial.
>
> I have a scriptable app I want to write AppleScript that targets the app via
> its bundle identifier rather than its name. But when I do what seems the
> obvious thing, I get a -1708 error, which I believe means the app doesn't
> understand the command I'm giving it.
>
> I wrote a trivially scriptable app to isolate and illustrate the problem.
> Here's my simple script, copied and pasted exactly from AppleScript Editor:
>
> get application id "com.yourcompany.TrivialScriptable"
> set myApp to result
> tell myApp
> activate
> greet("hello!!!")
> end tell
>
> If you're seeing the above as rich text, notice how "greet" is not bold and
> blue, indicating that the AppleScript compiler indeed thinks my app does not
> implement the "greet" command.
>
> I'm pretty sure I've set up the app correctly, because targeting it via the
> app name works:
>
> tell application "TrivialScriptable"
> activate
> greet ("this works")
> end tell
>
> In this case the "greet" is properly highlighted.
>
> What am I missing here? Is this some quirk of AppleScript?
>
> Note: I want to use the bundle identifier rather than the app name because in
> the case of my real app I have an iOS app with the same name. This means
> there is an XXX.app sitting in the build directory of my iOS project. This
> confuses AppleScript into targeting the wrong XXX.app.
>
> If you want to see this for yourself, a 26K zip file containing the code for
> TrivialScriptable is in my public iDisk (user aglee). Build the app and try
> running the above AppleScript snippets in AppleScript Editor.
>
> If I can't solve this I may change my approach and define a custom URL scheme
> and use that rather than AppleScript for the inter-app communication I need.
>
> --Andy
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]