Apple Script Plugin (Composition by dust)

Author: dust
License: (unknown)
Date: 2009.09.26
Compatibility: 10.6
Categories:
Required plugins:
(none)

Not sure if an Apple Script plugin for QC exists or not, seemed like a good idea to me. Control iTunes from within your composition. 10.6 64/32bit build. Source and Example Included.

PreviewAttachmentSize
d_AppleScriptQCPluginSL.zip51.27 KB

dust's picture
Re: Apple Script Plugin (Composition by dust)

i don't really know apple script but i am sure someone could have some fun with this.

other than to control itunes you can do java script which i am more familiar with than apple script.

example.

tell application "Safari" activate do JavaScript "window.open('http://www.pixel8r.info')" in document 1 end tell

i suppose you can do things like this...

do shell script "cd ~/Documents; ls"

actually i thought of making this plugin a provider and making a structured outlet so you can view your event loging but maybe that might give you to much control. YES:NO?

.lov.'s picture
Re: Apple Script Plugin (Composition by dust)

I never used Applescript, but the idea is good.

And i really love to see many people make plugins for qc, adding new features, more possibility.

So, the plugin is nice :)

dust's picture
Re: Apple Script Plugin (Composition by dust)

id rather not say how much coding went into this.. but thanks all the same much .lov.

dust's picture
Re: Apple Script Plugin (Composition by dust)

here is how you would interpolate the volume fader and turn on the eq in itunes from QC.

PreviewAttachmentSize
askVol.qtz3 KB

cybero's picture
Re: Apple Script Plugin (Composition by dust)

There once was an Apple Script plugin for QC, but it was not kept up to date with system updates and new OS X distros.

Also previous discussions about the use of Apple Script as a way of communicating with apps external to QC.

http://kineme.net/Discussion/DevelopingCompositions/HiroakiApplescriptPatch

Scripting up the QC app itself - well - I haven't tried the osax extension, which last time I looked was still non SL friendly, but it does provide scriptability for applications lacking an AppleScript dictionary of their own.

Finally, when compiling I got these errors, which seem none too important, as the plugin is still produced , but thought I'd mention them anyways.

Build ask of project ask with configuration Release
 
CompileC build/ask.build/Release/ask.build/Objects-normal/x86_64/askPlugIn.o askPlugIn.m normal x86_64 objective-c com.apple.compilers.gcc.4_2
cd /Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask
setenv LANG en_US.US-ASCII
/Developer/usr/bin/gcc-4.2 -x objective-c -arch x86_64 -fmessage-length=0 -pipe -std=gnu99 -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -Wreturn-type -Wunused-variable -isysroot /Developer/SDKs/MacOSX10.6.sdk -fobjc-gc -mmacosx-version-min=10.6 -gdwarf-2 -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/ask.hmap -F/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/Release -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/Release/include -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/DerivedSources/x86_64 -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/DerivedSources -include /var/folders/PS/PSRjktrJH-exhdWI5TM2uE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/ask_Prefix-blhnqiawfrwzyadtfoxgioybbicp/ask_Prefix.pch -c /Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/askPlugIn.m -o /Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/Objects-normal/x86_64/askPlugIn.o
 
/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/askPlugIn.m: In function '-[askPlugIn(Execution) execute:atTime:withArguments:]':
/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/askPlugIn.m:138: warning: unused variable 'returnDescriptor'
 
CompileC build/ask.build/Release/ask.build/Objects-normal/i386/askPlugIn.o askPlugIn.m normal i386 objective-c com.apple.compilers.gcc.4_2
cd /Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask
setenv LANG en_US.US-ASCII
/Developer/usr/bin/gcc-4.2 -x objective-c -arch i386 -fmessage-length=0 -pipe -std=gnu99 -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -Wreturn-type -Wunused-variable -isysroot /Developer/SDKs/MacOSX10.6.sdk -fobjc-gc -mmacosx-version-min=10.6 -gdwarf-2 -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/ask.hmap -F/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/Release -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/Release/include -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/DerivedSources/i386 -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/DerivedSources -include /var/folders/PS/PSRjktrJH-exhdWI5TM2uE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/ask_Prefix-bjzzjpzaahiqulgkyozcxsnecyxt/ask_Prefix.pch -c /Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/askPlugIn.m -o /Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/Objects-normal/i386/askPlugIn.o
 
/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/askPlugIn.m: In function '-[askPlugIn(Execution) execute:atTime:withArguments:]':
/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/askPlugIn.m:138: warning: unused variable 'returnDescriptor'
 
CompileC build/ask.build/Release/ask.build/Objects-normal/ppc/askPlugIn.o askPlugIn.m normal ppc objective-c com.apple.compilers.gcc.4_2
cd /Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask
setenv LANG en_US.US-ASCII
/Developer/usr/bin/gcc-4.2 -x objective-c -arch ppc -fmessage-length=0 -pipe -std=gnu99 -Wno-trigraphs -fpascal-strings -Os -Wreturn-type -Wunused-variable -isysroot /Developer/SDKs/MacOSX10.6.sdk -fobjc-gc -mtune=G5 -mmacosx-version-min=10.6 -gdwarf-2 -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/ask.hmap -F/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/Release -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/Release/include -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/DerivedSources/ppc -I/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/DerivedSources -include /var/folders/PS/PSRjktrJH-exhdWI5TM2uE+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/ask_Prefix-apgcflicptsekafvnchohwqmnmlo/ask_Prefix.pch -c /Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/askPlugIn.m -o /Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/build/ask.build/Release/ask.build/Objects-normal/ppc/askPlugIn.o
 
/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/askPlugIn.m: In function '-[askPlugIn(Execution) execute:atTime:withArguments:]':
/Users/cybero/Desktop/d_AppleScriptQCPluginSL/source/ask/askPlugIn.m:138: warning: unused variable 'returnDescriptor'

Great little piece of work :-)

monobrau's picture
Re: Apple Script Plugin (Composition by dust)

Nice one!

I was figuring out how to control apps via the command line plug and osascript, but this makes it so much easier.

Thanks!

dust's picture
Re: Apple Script Plugin (Composition by dust)

yeah thats just the warning error that im not using the return error feature if that makes any since. nothing to worry about unless you anticipate on making errors.

i have been thinking about returning the error as a structure to use in a provided context so a user could have feedback or a sort of console log to do shell scripting which i really think would be convenient.

i'm not sure how "safe" that would be floating around the internet but it seems reasonable plus could provide some basic remote management functionality. i suppose it would take a bit of effort to be malicious if used in the wrong way, and its only another line of code so i will update it in a bit.

as far as any support, with apple script ? im not the right guy to be asking, but the apple script editor comes with every mac so if your code is doing what intend inside the apple script editor then it will work with the plugin, so far as i have tested.

it does seem to want carriage returns so if your using the string printer to concatenate a string of code remember to hit option return to /n your lines. actually just a copy from apple script editor to the plugin seems to work fine but i think there could be instances where you would want to use some sort of variable from a qc function inside your apple script.

never herd of osax will look into that. i hope this works out better for people than the hiroaki patch. i'm not surprised that someone hasn't attempted this before. its kind of one of those plugins you don't know you need until you have it guess. at least i didn't really know how useful it was till i made it.

[edit]

here is a warning free build.

PreviewAttachmentSize
d_AppleScriptQCPluginSL.zip60.95 KB

Ksul's picture
Re: Apple Script Plugin (Composition by dust)

Hi dust,

I'm able to get your plugin to function. Nice work.

I would love to use the plugin unsafe so that I can run in a Keynote presentation to trigger some events.

Inside KinemeCore it shows up as an official API. Any suggestions how I can run it unsafe?

cybero's picture
Re: Apple Script Plugin (Composition by dust)

This works like a charm on 10.6.x .

dust's picture
Re: Apple Script Plugin (Composition by dust)

cool glad someone is using this. it was my first plugin. its only a few lines of code i will see if i can copy it over to the un official api and find the magic unsafe button or see if it can be enabled in kcore. this could be a very cool plugin unsafe i suppose. i last used this with some ui element applescripts to control finder windows and what not from qc. i actually like apple script just don't know it that well. there are a ton of libraries that could make this plugin very powerful. give me a couple hours and i will see what i can muster up. actually have to download the plugin again i lost my backup drive a few months ago.

Ksul's picture
Re: Apple Script Plugin (Composition by dust)

That would be great if you could make a unofficial API version!

dust's picture
Re: Apple Script Plugin (Composition by dust)

ok i put some time into figuring the skanky sdk. i like it. right now it seems to only work with leopard. now i built this in snow leopard and was able to run and debug in xcode and everything works fine. the issue is once i close x-code the plug-in disappears. k-core recognizes this plugin. so i'm providing it to you as in no guarantees. i'm pretty sure this will work fine on a 10.5 machine which i do not have anymore. please let me know if it works for you.

PreviewAttachmentSize
AppleScript.plugin.zip32.89 KB

Ksul's picture
Re: Apple Script Plugin (Composition by dust)

Hi dust. Thanks for this.

I'm running a 10.6.3 machine. I'm able to get the new plugin to work inside QC. The plugin is showing up in the "Plugin" tab in KinemeCore prefs but not showing up in the "Unsafe mode" tab. Please see attached. How can I get this to show in the "unsafe mode" tab? Any ideas?

Thanks!

dust's picture
Re: Apple Script Plugin (Composition by dust)

my bad... for what ever reason i thought all un-official patches where un safe. as it turns out you need to explicitly tell the patch be un-safe. sorry here is a un-safe plug.

so that is great news for you that this plugin shows up bad new for me as there must be something wrong with my system. i'm going to clean out my plugins folder. maybe that will help ???

here is a pic confirming that k-core will make this patch work.

PreviewAttachmentSize
a.s.k.not_.safe_.zip32.47 KB
safe.png
safe.png114.35 KB

Ksul's picture
Re: Apple Script Plugin (Composition by dust)

I feel that this is so close!

I was able to get the plugin to show up in the Unsafe Mode tab. Unfortunately I can't get anything to happen with the plugin outside of QC. I'm attaching a test composition. be careful as it wants to write to create and write to a text file at the root level. If I open this in Quicktime 7 or Keynote, I get nothing. I also tried your askVol test file and it too doesn't work "un-safe".

Any suggestions? Maybe I'm using unsafe incorrectly? I tried it with QC open and closed in the background - no difference.

Nonetheless, Dust, thanks for your help trying this today. It would be great if I can get Applescripting to work from inside s Keynote slide!! I have some scripting currently that calls out to hardware that does show control. Currently I have to use Remote Buddy to run a separate script that also tells Keynote when to move slide forward or back. The problem is that I'm stuck using only the remote devices that Remote Buddy deems as "compatible". If I could embed an Applescript that triggers when I enter a slide, that would be awesome!

PreviewAttachmentSize
writeFile.qtz1.21 KB

dust's picture
Re: Safe Apple Script Plugin (Composition by dust)

ok there is a bit of confusion as per safe and unsafe. kineme core lets you enable unsafe plugins to be safe that is why i sent you a unsafe plugin.... because you where wanting to use kineme core. for what ever reasons kineme core isn't working the way its supposed to and not enabling the plugin to be safe when it is unsafe hence the not working outside qc bit. i guess in theory the k-core method should work.

so lets forget about kineme kore. don't use it. nuke all the apple script plugins. and add the safe apple script plugin to your patches folder. and your golden. i only have the mobile version of keynote. so i tested this with safari. now i know this patch is safe but how safe is it to have an applescript plugin embedded into a webpage ???

so your good with this....

PreviewAttachmentSize
Safe.Apple_.Script.plugin.zip32.48 KB

Ksul's picture
Re: Safe Apple Script Plugin (Composition by dust)

Still no luck. Followed your instructions. I too was able to get it to function inside Safari but still no luck in Keynote. Oh well. Thanks for the effort. :)

dust's picture
Re: Safe Apple Script Plugin (Composition by dust)

I'm sorry I don't have keynote on my system. I should put it back on. as far as I have read there is only limited support of qc from within keynote. obviously I understand the possibilities of an apple script plugin, but there are other ways to switch a slide from a remote. my preferred method of remote communication is o s c. there is a program called ocsculator with you can do all kinds of virtual routing of remote signals. with it you can let's say send a signal via wifi with from an iPod then one route that signal to qc to do something as well as convert the o s c signal to a key code let's say the arrow key which in turn will change the slide in key note. are there not remotes built specifically to change slides in keynote? either way anything keynote can do qc can do. maybe not as intuitively but certainly transitioning image and text should be pretty easy in qc.

Ksul's picture
Re: Safe Apple Script Plugin (Composition by dust)

Hmmm, never seen ocsculator before. I'll check it out. The problem I'm having is that I need a remote that Keynote is not listening to. Currently I'm using the Keyspan Remote for Front Row. This device is supported in Remote Buddy. In Remote Buddy, a right arrow from the Keyspan remote, communicates directly to Remote Buddy where I have the software set up to run a custom Applescript.

This entire effort is so that I can show these beautiful multimedia presentations from Keynote. It's awesome! 5.1 audio, 1080 video out to a projector or TV. It's the delivery mechanism for the demonstrating product for my company. The icing on the cake came two years ago where a guy working with me wondered if we could put lighting cues into the presenter notes area of the Keynote. This would allow control of all sorts of things like DMX lighting dimmers, moving lights, smoke machines, serial devices (using Lanbox LCX), IR controllers.

Unfortunately, to do this, I need to hijack a wireless remote's signal, run my script which yanks any lighting cues out of the next Keynote slide, tell Keynote to advance the slide, and finally execute any cues that were specified on the slide. It works awesome.. .except for one thing. We have the dramatic moments where lights come on in certain times of the embedded QT movie on the Keynote slide. I have one slide that literally has over 100 cues - from lights going on/off to serial commands, to electromagnets doing something... Because the QT doesn't always trigger as soon as the slide is transitioned (or some latency in my script), I'm seeing variance in when my lighting cues execute. Too bad Quicktime and Keynote don't allow events to occur/be triggered from timecode! But, QC does. If I was able to embed the HD movie and trigger my lights from a frame I would then have the precise timing I'm looking for (ala SMPTE code show control).

Sorry for being long winded but I thought if I gave you some more info you may have some other ideas since it seems like a knowledgeable crew here.

dust's picture
Re: Safe Apple Script Plugin (Composition by dust)

wow thought there had to be more to it than changing a slide... yeah not sure if keynote would be how i would go about this. im more into making custom apps i guess. although with the minimal controls keynote has you could actually use to make animations. i suppose to present hd videos that have lighting macros attached to them would be fairly easy in qc. you would want to use two qc files one for notes and once for presentation. and use spooky or osc to bounce sync mu things. as per getting smpte accurate timing out of qc thats yet to be done but certainly you can transition slides and trigger lights with no latency.

look into osculator its pretty solid remote control app. osc, midi, apple script, key commands, hid, mouse, etc...

gtoledo3's picture
Re: Safe Apple Script Plugin (Composition by dust)

You may wish to consider building your own app in QC and forgetting about Keynote. Reading what you are doing, my opinion is that you are making way more work for yourself, and a scenario where things will never work quite right by using Keynote to host this.

If you are using Keynote for is to advance slides/show scenes (eg., alternating between your qtz's), you could approach that in QC in a number of ways. You can have your items inside of macro's and then use a Demultiplexer to turn on the specified macro ("slide") and turn Off the others (go into Settings). The other approach would be to stuff all of your compositions into Render In Image patches, hook each to a Multiplexer, and then onto a Billboard or Sprite.

One could also build something that took advantage of all of the stock transitions, or some custom transitions.

Once you have your qtz setup, you can turn it into an app using Quartz Builder. That will allow it to always open at a specific pixel w/h, in the same place on a given computer every time, and allows a number of other options - window level, an automatic published parameter interface if desired, qtz encryption, GPU multisampling, and it also runs plugins and patches... it pulls them automatically during the build process, as well as resources that are in a file location relative to your qtz.

You can get 5.1 audio with SL's audio player as well.

QT can really crap out when trying to load HD video at very precise moments. Just because you can use QC to trigger the event, doesn't mean that the movie will actually load reliably at that precise split second every time. File size and codec can change the results considerably.

Are you trying to make things in the composition determined by the current location ("movie position") from the movie patch?

Ksul's picture
Re: Safe Apple Script Plugin (Composition by dust)

Thanks for the info guys, very helpful. I wish I could work exclusively in QC but since I need to hand off these Keynotes to other folks of varying technical abilities around our global offices, I need to ensure that the Keynotes are customizable. So it's just not a series of QTZ files I'm looking to play, I need the slides with text, Keynote animations, and other elements that need to change to be adaptable for a local market's needs.

I'm going to keep my hopes alive that there's some way to communicate events from inside Keynote. I understand this is not on Apple's radar (from previous post by usefuldesigns) but this would be awesome.

dust's picture
Re: Safe Apple Script Plugin (Composition by dust)

honestly if your going to be sending your presentation material around to satellite offices or what have you keynote is a good choice as most people now know how to use powerpoint or keynote.

i remember back in the day when i used to make 75 dollars an hour just printing a powerpoint document. in the 90's people where just scared of this tech. so i agree that keynote would be a good choice because most people could open your template up and edit to their needs. the problem is the applescript plug is not working in keynote.

so i suggest that you not base your product solely upon someone else's technology meaning apples unless your affiliated with apple and to make a simplified version of the keynote program to suite your needs.

so suggestions would be to make a proprietary simplified app that suites your needs with boiler plate templates and drag and drop ease like keynote.

or to do this as a local web based or browser based templates solution. seeing the apple script plugin works in the browser via qtz you can easily integrate the keynote experience in a browser. keynote or iWork is soon to be web based anyways, or is in beta right now. check iWork.com

seeing that embedding a quartz file to be viewed on a web page is very simple you can just use letss say the apple remote patch for qc to trigger things. i would say look into html 5 it works like keynote does now with slide transitions and what not. i'm not saying make it server based although that would be ideal in the long run but just local file based where all your clients have to do is launch your slide viewer page and your notes page.

then making a simple sort of backend configuration page to edit your presentations.

this can all be done in quartz builder but unfortunately right now you can not just drag and drop a file onto the viewer but you can certainly make a template and have your clients edit that template via resources. so for instance moviePage1.mov arbitrarily can be any movie with the same name. so thats easy enough for clients to just put there own movies in. as per the notes thats the easy part. you would just read in your data via a textfile. so your clients would only have to open the text file an put there own words in. again a boiler plate template application.

again you can certainly add interactions very easily now as well with qc4. so letting users actually place the text movie picture etc... where ever they want on screen is also possible.

i know keynote is universal as im a student and watch keynote powerpoint slides all day but it sounds like your project is something more than just a regular presentation. especially if your interested in selling your presentation technique you don't want to base that on the requisite that the client has keynote because some people like powerpoint.

although it sounds like your pretty set on using keynote. there has to some solution. like i mentioned earlier apples ramping up iwork to go browser based so pretty soon the keynote application will be irrelevant. i know i have gone over to mobile keynote.

i will though later put keynote on my system and further investigate things. today i'm playing with cocos2d and particle designer. want to get back into doing some more artistic based things. i found myself getting deeper into coding an forgetting about my art although if you ask me coding is an art as well. its been a while since i posted an artistic piece. been geeking out lately i guess.

will let you know if i find a solution though. im glad someone is using my apple script plugin. i have done some really cool experiments with like controlling my finder via multi-touch with inertia added to UI windows etc.. was thinking of uploading a display script so people could easily display alert windows with options from qc.