AppleScript in wrapped app

I have an app that uses Applescripts. I wrapped the app with App Wrapper but it appears wrapped apps can’t run Applescripts. Is this correct?

Have you specified Apple Events Entitlements?

In App Wrapper, under the “Apple Events & Specific Files” heading, you need to add the applications that you are Apple Scripting.

Apple is very slowly migrating over to a newer system for Apple Script & Sandbox, the current App Wrapper doesn’t really support it. Mind you, the current apps don’t really support it either.

Thanks Sam! That seems to have been the ticket!!!

You’re welcome.

[quote=100220:@Sam Rowlands]Have you specified Apple Events Entitlements?

In App Wrapper, under the “Apple Events & Specific Files” heading, you need to add the applications that you are Apple Scripting.

Apple is very slowly migrating over to a newer system for Apple Script & Sandbox, the current App Wrapper doesn’t really support it. Mind you, the current apps don’t really support it either.[/quote]

I though AppleScript was purely banned. That opens new perspectives. Is that possible with App Wrapper Mini as well ?

I think I found how to do it by myself.

  • in AWM I go Edit/Edit “Entitlements” in XCode
  • In Xcode sandbox.entitlements file, I add a row, with as key com.apple.security.temporary-exception.apple-events and value the bundle identifier of the application I will be scripting. I tried with com.apple.iphoto and was able to activate it from a shell to osascript within the sandboxed application.

Sam, I am correct ?

You often mention that temporary entitlements are dicy. Is it the case here ? I kind of remember reading in the forum that system events are taboo when sandboxed. Are there apps I am not supposed to script ?

[EDIT] : The app successfully launched iPhoto but looking at the Console, I find :

6/15/14 6:15:59.020 AM osascript[989]: Error loading /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: dlopen(/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions, 262): no suitable image found. Did find: /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: mach-o, but wrong architecture

and several

6/15/14 6:16:03.590 AM appleeventsd[53]: Sandboxed application with pid 989 attempted to lookup App:"iPhoto"/990/0x0:0x71071 iPho1000 sess=100004 but was denied due to sandboxing. (___ZL13handleMessageP17_xpc_connection_sPv_block_invoke260()/appleEventsD.cp #2413) client-reqs-q

Strange…

Some things are outright banned, such as scripting finder, terminal, system preferences and system events. Others require explanation as to why you need this.

My advice, is simple. Don’t design an application that uses Apple Script, look for alternatives (such as APIs). If you’ve already built an app, then fine.

[quote=100551:@Michel Bujardet]I think I found how to do it by myself.

in AWM I go Edit/Edit “Entitlements” in XCode
In Xcode sandbox.entitlements file, I add a row, with as key com.apple.security.temporary-exception.apple-events and value the bundle identifier of the application I will be scripting. I tried with com.apple.iphoto and was able to activate it from a shell to osascript within the sandboxed application.
Sam, I am correct ?[/quote]
Correct, except don’t use the shell to execute Apple Scripts, instead you need to use NSAppleScript. MBS has this as I suspect MacOSLib does also.

Correct. The list I’m aware of is above, however you should note that Apple are phasing out the temporary exception in favor of a new key and format. The trouble is, it’s incredibly limited as to what can use the new system and the functionality that is available.

For instance Apple Mail can now only be instructed to generate a blank e-mail. You can do this via ShowURL and get it to auto enter an address and content, without the need of Apple Script or special entitlements.

I’m working on a new system for adding Apple Script entitlements to your application, as a fair amount of people do use them.

As for the errors, They do look a little odd… Wrong architecture?

I have 2 applications in the MAS that use Applescript. They read from Microsoft Word for example or from Safari or Chrome. They were accepted on the MAS with no particular problem.
As Sam wrote above, this was not the case when I tried to use Applescript for the Finder though.

I have an app where I would like to place a smal window looking like an icon on the lower left corner of the screen. That is, if the dock is not wide enough to cover that area. Otherwise I will place it just above.

The only method I could find uses System Events to get the size of the dock. It is posted at http://j4mie.org/blog/how-to-get-the-dimensions-of-the-dock/ . So I guess I will have to forget that.

Unless there is a kosher way of getting the size of another running application current window, I see no real alternative but to come back to the first idea I had, which is to scan the screen on a small square from the left edge right-ways until I encounter the characteristic grey of the dock. It is not impossible, if cumbersome :wink:

I’ve not seen or heard or anything for doing this, except maybe hacking the dock’s preferences… Which is course is also not permitted from a Sandboxed application.

The easiest solution I can think of is to allow the user to move and resize the window, not very elegant I know, but simplifies things for you the developer.

[quote=100779:@Sam Rowlands]I’ve not seen or heard or anything for doing this, except maybe hacking the dock’s preferences… Which is course is also not permitted from a Sandboxed application.

The easiest solution I can think of is to allow the user to move and resize the window, not very elegant I know, but simplifies things for you the developer.[/quote]

Thank you. I just found a way. Trying to keep in topic, I have posted it in a previous discussion about that at
https://forum.xojo.com/12744-is-the-dock-here