How to AppleScript FInal Cut Pro using Apple Events?

Hi,

I know it’s not possible to applescript Final Cut Pro.
However it is possible to talk to Final Cut Pro, or FCP, through Apple Events.
http://developer.apple.com/samplecode/FinalCutPro_AppleEvents/index.html
However that is all obj-c and I’m not very good in that :wink:

Since Apple Events are used by AppleScript with most scriptable applications I was wondering if there was a way to applescript FCP.
All I need is to automate is for FCP to export an XML of an fcp project file.

Is this possible?

Thanks in advance.

Jasper

Usually, you can script anything with System Events that you can manually do by selecting from a menu or hitting a keystroke. Getting the syntax right for menu selections is usually pretty difficult. If the export command you are trying to automate has a keyboard shortcut that might be easy.

Try something like this:

tell application "System Events"
	tell process "Final Cut Pro"
		--if the keyboard shortcut for export was command-shift-e for example:
		keystroke "e" using {command down, shift down}
	end tell
end tell

Then add delays to make sure the script doesn’t get ahead of the program and add additional key commands. This will only work obviously if you are able to manually perform the whole process with the keyboard.

You can send events to FCP from AppleScript using its raw chevron-based syntax. You can’t get results back as FCP stupidly packs return values into reply events under a non-standard parameter key. This may not be a problem if you’re only doing exports; if it is, you’ll need to use C/ObjC or a patched copy of appscript. ISTR someone once working on a Python module for controlling FCP via appscript; I don’t know if it ever got released though.

Thanks guys.

I figured something out.
To open a project file you could simply doet.


	tell application "Final Cut Pro"
		«event KeyGofcP» given «class fcpP»:POSIX file aFile
	end tell

this works but it doesn’t work to export a file using


	tell application "Final Cut Pro"
		«event KeyGeXML» given «class fcpP»:POSIX file aFile
	end tell

Anyone an idea to get the result stream back?

Again, AppleScript can’t see values returned by FCP because FCP is a big lump of stupid. You will have to use the system C/ObjC APIs (packaged as an osax or wrapped in an ObjC class an invoked via Studio’s ‘call method’ if you want to use it from AppleScript), or appscript (which can be modified to extract the relevant data from the reply events).

Would you happen to know how this is done via Obj-C?
Since my Obj-C is very poorly.

I’ll look into appscript.

Did you get that to work?

NO I haven’t.