CommandPost allows you to create Lua code snippets, which appear as actions in CommandPost's Search Console.
This means you can trigger a snippet via a shortcut key or control surface button.
For example, to launch Final Cut Pro, you can use this simple Lua code:
cp.apple.finalcutpro:launch()
CommandPost is also compatible with Hammerspoon, so you can also use any of the examples on the Hammerspoon website:
​http://www.hammerspoon.org/go/​
You can learn more about Lua here:
​https://dev.commandpost.io/lua/lua-overview​
local bundleID = "com.logitech.manager.daemon"local apps = hs.application.applicationsForBundleID(bundleID)if apps and apps[1] thenapps[1]:kill9()endhs.application.launchOrFocusByBundleID(bundleID)
cp.apple.finalcutpro:launch()local clips = cp.apple.finalcutpro:timeline():contents():clipsUI()table.sort(clips, function(a, b) return a:position().x < b:position().x end)local evenClips = {}for i, clip in ipairs(clips) doif (i % 2 == 0) thentable.insert(evenClips, clip)endendcp.apple.finalcutpro:timeline():contents():selectClips(evenClips)
hs.eventtap.keyStroke({}, "-", 0)hs.eventtap.keyStroke({}, "2", 0)hs.eventtap.keyStroke({}, "0", 0)hs.eventtap.keyStroke({}, "0", 0)hs.eventtap.keyStroke({}, "0", 0)hs.eventtap.keyStroke({}, "return")cp.apple.finalcutpro:doShortcut("JogForward"):Now()
hs.eventtap.keyStroke({"shift"}, "]", 0)hs.eventtap.keyStroke({}, "-", 0)hs.eventtap.keyStroke({}, "1", 0)hs.eventtap.keyStroke({}, "0", 0)hs.eventtap.keyStroke({}, "return", 0)hs.eventtap.keyStroke({"cmd"}, "up", 0)​-- Need To Assign Toggle Fade Out in FCPXhs.eventtap.keyStroke({"cmd", "alt"}, "f", 0)hs.eventtap.keyStroke({"cmd"}, "down", 0)​-- Need To Assign Toggle Fade In in FCPXhs.eventtap.keyStroke({"cmd", "shift"}, "f", 0)hs.eventtap.keyStroke({"ctrl"}, "s", 0)
hs.eventtap.keyStroke({"shift"}, "]", 0)hs.eventtap.keyStroke({}, "-", 0)hs.eventtap.keyStroke({}, "1", 0)hs.eventtap.keyStroke({}, "0", 0)hs.eventtap.keyStroke({}, "return", 0)hs.eventtap.keyStroke({"cmd"}, "up", 0)hs.eventtap.keyStroke({"cmd"}, "down", 0)​-- Need To Assign Toggle Fade In in FCPXhs.eventtap.keyStroke({"cmd", "shift"}, "f", 0)hs.eventtap.keyStroke({"ctrl"}, "s", 0)hs.eventtap.keyStroke({}, "down", 0)hs.eventtap.keyStroke({"shift"}, "[", 0)hs.eventtap.keyStroke({"shift"}, "=", 0)hs.eventtap.keyStroke({}, "1", 0)hs.eventtap.keyStroke({}, "0", 0)hs.eventtap.keyStroke({}, "return", 0)hs.eventtap.keyStroke({"cmd"}, "up", 0)hs.eventtap.keyStroke({"cmd"}, "down", 0)​-- Need To Assign Toggle Fade Out in FCPXhs.eventtap.keyStroke({"cmd", "alt"}, "f")hs.eventtap.keyStroke({"ctrl"}, "s")
hs.eventtap.keyStroke({"shift"}, "[", 0)hs.eventtap.keyStroke({"shift"}, "=", 0)hs.eventtap.keyStroke({}, "1", 0)hs.eventtap.keyStroke({}, "0", 0)hs.eventtap.keyStroke({}, "return", 0)hs.eventtap.keyStroke({"cmd"}, "up", 0)​-- Need To Assign Toggle Fade In in FCPXhs.eventtap.keyStroke({"cmd", "shift"}, "f", 0)hs.eventtap.keyStroke({"cmd"}, "down", 0)​-- Need To Assign Toggle Fade Out in FCPXhs.eventtap.keyStroke({"cmd", "alt"}, "f", 0)hs.eventtap.keyStroke({"ctrl"}, "s", 0)