MAS, Sandboxing and AppleScript?

What is the current situation with AppleScript and Sandboxing? Is anyone having an app in the Mac App Store which uses AppleScripts to control other apps (like MS Word or Excel)?

Are apps accepted to the MAS which make use of temporary exception keys, as described in this blog-post? :
http://www.artisantech.com/log/2011/10/in-the-app-store-but-outside-the-sandbox-login-items/

If not, are there any ways on how a Sandboxed app can open a specific template in another app and then pass data to it?

The blog above is from 2011, is anyone having more recent experience with it?

Oliver

Using temporary entitlements is a hit and miss situation. Especially with Apple Script, Apple do allow Apple Script entitlements, providing that they cannot be used with malicious intent. So scripting the Finder is out of the question as it could potentially allow the Sandboxed application access to the entire users file system and negates the Sandbox.

Yet some companies (mainly the bigger ones), even have TEs that allow the app full access to the file system. So it can be done, but what’s the secret, I guess probably money…

I know that RS has built-in objects for working with Microsoft apps, if you’re targeting these specific apps then maybe these will work?

[quote=8832:@Sam Rowlands] So scripting the Finder is out of the question as it could potentially allow the Sandboxed application access to the entire users file system and negates the Sandbox.[/quote]The following script works in Sandbox mode, when I’m adding com.apple.finder to ‘Apple Events & Specific Files’ section of AppWrapper (when the template is found in the container):

tell application "Finder" set myPath to ((path to home folder) as text) & "Documents:Seminar Pro:templates:imLabels.dotm" set thePath to a reference to alias myPath open thePath as alias end tell
But if I understand right, then I have to avoid any call to Finder, otherwise the app will most likely not be accepted on MAS. I can work around this by working directly with specific apps like MS Word (by adding com.microsoft.Word in AppWrapper, etc). I do something like this:

tell application "Microsoft Word" activate if length of param1 > 0 then open (path to home folder as string) & "Documents:Seminar Pro:templates:" & param1 end if end tell

[quote=8832:@Sam Rowlands]I know that RS has built-in objects for working with Microsoft apps, if you’re targeting these specific apps then maybe these will work?[/quote]AFAIK, they are Windows only. I do not see any other way than using AppleScript to control Office Apps on OSX. And Apple seems to discourage us from using AppleScript. How else would we then make use of existing solutions? For the sake of ‘security’, do we have to reinvent the wheel now again and again, like coding a WordProcessor and SpreadSheet into each and every app?!

Indeed - thats how it seems. I tried to get Apple to give a definitive guide to using TEs, like under what circumstances, but the Apple engineer said it’s taken on a case by case situation, except for the Finder where it’s off limits. (As far as MAS is concerned).

Which is part of the reason that App Wrapper is not available on the Mac App Store :frowning:

I didn’t know if they were for Windows or not as I’ve never used them.

Does your app bundle contain the templates? If so you might be able to request NSWorkSpace to open the template in Word for you.

NSWorkSpace, that was the missing link. Thanks for the hint! That is what I was hoping for, when I initially posted on this thread.

And yes, I do have some sample templates in my app, which get called from a XojoScript. Using NSWorkSpaceMBS, I will probably be able to add a function to XojoScript so that a user can call his own, selfmade templates.

Something in this example’s direction will probably do it for me (found at Monkeybread’s):

[code]dim f as FolderItem
f=SpecialFolder.Desktop.Child(“test.txt”)

if NSWorkspaceMBS.openFile(f,“BBEdit”) then
MsgBox “Ok”
else
MsgBox “failed”
end if
[/code]

It should do, we use NSWorkSpace to allow our users to select an application when they export photos from our application.

I use the NSSavePanelMBS functions to inject an accessoryView into the SavePanel, where I allow users to select the application (take a look at “Shine” on my site for an example). Then once the exported image has been generated, I call NSWorkSpace to open the image into the chosen application.

I’ve seen on the Apple forums, people moaning that this function doesn’t work for them, so it may have something to do showing the SavePanel first, I don’t know.

@ Sam: What about com.apple.systemevents? Adding it to the temporary entitlements, would this be a no-go for MAS as well?

I would like to use AppleScript code like this:

-- hit tab-key to move to next cell tell application "System Events" keystroke tab end tell

BTW, When I copy the template into the container’s documents folder, then the following code works fine in a sandboxed app (Without any special entitlements and without using SavePanel).

This launches Word and creates a new document based on template “imLetter.dotm”:

Dim f As FolderItem f=SpecialFolder.Documents.Child("imLetter.dotm") If Not NSWorkspaceMBS.openFile(f,"Microsoft Word") Then MsgBox "failed" End If

Unfortunately it looks very likely that you might get rejected for it, at least this poor soul did at stackoverflow .

A pattern emerges… Your placing the file within a location where your application has access to the file (just like when I used the save dialog). So maybe this people complaining are not using files that they have access too?