We have a sandboxed Final Cut Pro (FCP) workflow extension that needs to control FCP to export the current video project. When executing an AppleScript, we encounter the error: "System Events got an error: FCPExtension (Final Cut Pro) is not allowed assistive access." This occurs despite the container app having been granted automation and accessibility permissions by the user. What could be missing from the project to ensure the script runs without issues?
AppleScript:
shareDestination("Destination")
on shareDestination(_dest)
tell application "Final Cut Pro"
activate
end tell
tell application "System Events"
set frontmost of process "Final Cut Pro" to true
tell process "Final Cut Pro"
perform action "AXRaise" of (first window whose name contains "Final Cut Pro")
click menu bar 1
tell menu bar 1
tell item 3 of menu bar items
tell menu 1
tell menu item 12
tell menu 1
set menuItems to menu items whose title is (_dest & "…")
if length of menuItems > 0 then
set targetMenuItem to item 1 of menuItems
if enabled of targetMenuItem then
try
click targetMenuItem
on error errMsg number errNum
error errMsg
end try
else
error "Share destination is not enabled." & return & "Please try selecting an item in Final Cut Pro."
end if
else
error "Share destination not found."
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end shareDestination
As soon as the script reaches set frontmost of process "Final Cut Pro" to true
it launches the error.