running applescripts?

Hi All

Can you run applescripts from XOJO and if so can someone point me in the right direction of how please?

this might help

http://www.106automation.com/page2/RB/RB.html

[quote=20723:@NG P]this might help

http://www.106automation.com/page2/RB/RB.html[/quote]
A gem! Thanks a lot!

[quote=20717:@damon iddins]Hi All

Can you run applescripts from XOJO and if so can someone point me in the right direction of how please?[/quote]
Yes
At least a few ways

  1. write a script & add it to your project directly then call it like any other method
  2. OSA Script in a shell
  3. MBS has plugins

For option 1 some quick & dirty steps

  1. write a script - save it as a SCRIPT (not an app)
    You can pass parameters & get return values from it (see Applescript references on how to write this in a script)
    If your script has other methods in it that’s ok just realize that the RUN handler is what will get called and that you pass parameters to & get results from.

  2. give the script a nice name as this will be the name of the method you call

  3. drag it into your application

write your app and call the script as though it were any other global method

For instance heres a short apple script that tells iTunes to play a playlist

[code]on run (whatList)

tell application "iTunes"
	set theList to playlist named whatList
	play theList
end tell

end run[/code]
Enter that into AppleScript editor and save as a script name “PlayPodcastList”
Create a new desktop app
Add a button
Drag the script in
Then in your buttons action event you can write

PlayPodcastList("PODCAST LIST" )

and if you have a playlist named that it should start playing

[quote=20717:@damon iddins]Hi All

Can you run applescripts from XOJO and if so can someone point me in the right direction of how please?[/quote]
If you’re building an app and intend to release it on the Mac App Store, you may want to reconsider using Apple Scripts as trying to Apple Script “Finder” and “System Events” will get your application rejected.

That brilliant ! Thank you all so much for your help.

Is there a way round it Sam , not using applescript? The app i want to interact with is a pro audio DAW called rto tools. It doesnt even have an apple script library built in so id have to use keyboard/menu commands when scripting anyway

Ahh… not that I’m aware of, you might like to try Apple DTS and see if they have any suggestions for you or if there is a way that can guarantee you the App Reviewer won’t reject your application. Controlling the keyboard/mouse is highly likely to get you rejected as it’s something should a hacker by able to get into your program, they could then take over the computer. Which is all possible but highly unlikely (in the 19 years I’ve been working with Mac, I’ve only once ever come across a virus).

I have no idea what rto tools are, they sound like something specific, which may not actually be a problem if you can’t get your application on the Mac App Store. The Mac App Store is more like a supermarket, where the most commonly sold things are mass market products. A highly specialized tool may sell just as well on your own site or via a site that sells Audio tools.

For instance we sell most of our products on both the Mac App Store and our own site, yet we still sell a large number of HDR apps on our own site.

The other idea is to contact the maker of the tool and see if they do have an external access mechanism, perhaps a IPC connection or shell scripting can be used. Maybe they could consider adding Apple Script support in the future?