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.
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.
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).