AppleScript from a plug-in

adamfenn28's picture

I'm working on a plugin that will automate the control of Syphon Recorder (stop/start) and automatically archive the recorded videos.

I have created simple AppleScripts that stop and start the video, and I'm working on using NSAppleScript to execute them. I'm looking for an intelligent way to locate the scripts. Normally I might use NSBundle mainBundle, but that returns the path for QC, rather than for plugin, my AppleScript resources under my plugin can't be found that way. Is there a good way to return the directory of the my plugin, or should I just assume it's ~/Library/Graphics/Quartz Composer Plug-Ins?

Also.. I think I'd rather use the Scripting Bridge, than include AppleScript resources in my plugin. sdef/sdp can't seem to find the necessary files to create the necessary header file for use in the Scripting Bridge. Is there a way to work around this, or even a better way to do AppleScript from within my plugin?

Thanks!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

dust's picture
Re: AppleScript from a plug-in

the first plugin i made was an apple script plugin. not very much code at all and now that i look at it there might be a memory leak. drrr

it can be found here with source....

http://kineme.net/composition/dust/AppleScriptPlugin

it runs a string input inside qc... the event descriptor isn't really doing anything.. i panned on returning the error and event in the future etc....

NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:self.inputScript];
NSAppleEventDescriptor *returnDescriptor = [scriptObject executeAndReturnError:nil];

to call an apple script from file.... i think it would be best to just use a string input as URL to the location of the file. that way you don't have to deal with where the plugin is located as a plugin can be loaded from any location plus it would make the plugin useful for other things and people...

this code assumes self.inputURL is of type string and previous declared....

[[NSAppleScript alloc]initWithContentsOfURL:[NSURL URLWithString:self.inputURL] error:NIL]

i think it would be cool to return the error as a structured output ? that would give feedback of your doing shell commands....

remember to release your script object ;)

borego's picture
Re: AppleScript from a plug-in

Are there any updates on this plugin you were working on? We're trying to do the exact same thing (trigger Syphon from within QC, then take the videos and throw them up on Drupal/YouTube), so having your plugin would make our lives a bit easier (I'm working on hand-coding one myself right now).

dust's picture
Re: AppleScript from a plug-in

here is a lion plugin build with qtz example of turning volume up and down in iTunes also the source to the plugin. let me know if this helps or not.

PreviewAttachmentSize
ask.zip63.28 KB