Haiku AppleScript issues

Hey guys, running into an issue when trying to use the sample code provided to fire off some applescript commands, whether I run this command from Haiku, or from HH. Here is the error I receive:

"Unhandled exception in script on line: 27 in function onButtonActivate: executeAppleScript(): AppleScript error: iTunes got an error: Application isn’t running."

Clearly iTunes is running, I have it open, can see playlists etc...


Here is my code (straight from the sample I believe)

// iTunes Code
function onButtonActivate(button) {
if(button.name == 'iTunes Play') {
helper.executeAppleScript(controller, 'tell application "iTunes" to play');
} else if(button.name == 'iTunes Pause') {
helper.executeAppleScript(controller, 'tell application "iTunes" to pause');
} else if(button.name == 'iTunes Prev') {
helper.executeAppleScript(controller, 'tell application "iTunes" to skip to previous track');
} else if(button.name == 'iTunes Next') {
helper.executeAppleScript(controller, 'tell application "iTunes" to skip to next track'); }
}
// End iTunes Code

I have also tried subbing in some other commands like 'tell application "Safari" to activate' (which should just launch Safari) These commands all work when pasted straight into Applescript Editor, I'm hoping I'm missing something simple. Any input or thoughts you can give you would be great.
 
Unfortunately the reason its not working is that Apple now requires all App Store apps to be sandboxed and sandboxing does not allow AppleScripting of third party applications without a "temporary exception" from Apple. We will request a temporary exception for iTunes in the next update.
 
Thanks again for the response lupinglade, do you have any estimate or timeframe for updates? how often are they done, etc? Just curious is all, not rushing. :)
 
We release updates fairly often, but not sure how quickly Apple will approve it given the needed temporary exception.
 
Hey Lupinglade, just wanted to follow up and see how the progress has come with getting Apple to give you an exception for applescript. Just curious is all. Thanks.
 
Well the error is now different so I guess we are closer! Here is the new error:

"Unhandled exception in script on line: 27 in function onButtonActivate: executeAppleScript(): AppleScript error: iTunes got an error: A privilege violation occurred."

And my Code, still from the sample I believe. My Buttons are named exactly like the callouts in the code, also line 27 is the "function onButtonActivate(button)"

Code:
// iTunes Code
function onButtonActivate(button) {
if(button.name == 'iTunes Play') {
helper.executeAppleScript(controller, 'tell application "iTunes" to play');
} else if(button.name == 'iTunes Pause') {
helper.executeAppleScript(controller, 'tell application “iTunes” to pause');
} else if(button.name == 'iTunes Prev') {
helper.executeAppleScript(controller, 'tell application “iTunes” to skip to previous track');
} else if(button.name == 'iTunes Next') {
helper.executeAppleScript(controller, 'tell application “iTunes” to skip to next track'); }
}

Any Thoughts?
 
I could create an applescript file for each action (play, pause, skip, play certain playlist etc) and then call those files, they would then be "run" by finder, so run by an administrator, but I don't see any docs on how to "run a file" I guess I could then create a shell script that would run the applescript, and fire that shell script off from php, but then I'm just stacking a lot of layers on top of each other... You have any further ideas Lupinglade? (If I'm just a moron and doing something really wrong, feel free to correct me!) :)
 
Unfortunately looks like Apple has put up yet another cross scripting road block. Makes you wonder what good that exception was?

I think your best bet would in fact be to make a php script that runs the apple scripts, it should be quite easy to get working and should be very reliable.
 
evanlifetv has given us a hint that may help make this work properly. The update after the next one will include this fix. Hopefully then you will be able to control iTunes directly via AppleScript.
 
Back
Top