AppleScript UI Scripting Slow?

Thanks for accepting me into your community!

I’ve been spending a lot of time searching these forums the last few days - it’s been INCREDIBLY helpful, so thank you!

I’ve recently been trying to solve a bunch of problems to make editing in Final Cut Pro (FCPX) better for the end user.

I’ve been using an awesome scripting tool called Hammerspoon (similar in function to Automator), which uses the Lua scripting engine - however, it also supports AppleScript, which is where I’ve been doing most of the work.

I’m new to AppleScript, so everything I’ve been doing has been very much through trial and error. I’m a filmmaker - not a programmer.

Even though it still needs a lot of work - I’ve already released my scripts on our blog for anyone who’s interested, to basically just gauge if people are interested in this kind of thing, and also get user feedback on any bugs that pop up, etc.

https://latenitefilms.com/blog/final-cut-pro-enhanced-match-frame/

It all seems to work fine - however I’ve hit some road-blocks that I’d love your advice on to try and solve.

  1. The biggest issue I have is speed.

For example, if I have 10 clips in the FCPX browser, and run the following AppleScript it works instantly:


activate application "Final Cut Pro"
tell application "System Events"
	tell process "Final Cut Pro"
		get position of value indicator 1 of group 1 of scroll area 2 of splitter group 1 of group 7 of splitter group 1 of window "Final Cut Pro"
		display dialog the result as string
	end tell
end tell

However, if there’s 800 clips in the FCPX browser, then the above AppleScript takes about 6 seconds to process. If there’s 1000’s of clips, then it takes ages, which is a big issue for what I’m trying to achieve.

Is there any way to speed this up?

Given that I’m asking AppleScript something very specific, I would have ASSUMED that how many other “groups” are in the program wouldn’t make any difference, but apparently not! Any suggestions would be greatly appreciated!

  1. Another question is about designing efficient code. For example, I feel like there’s definitely a better way to do this (using ‘whose’ statements for example) - but I couldn’t work it out. I feel like this is definitely something you could do in possibly even one line of code. Any suggestions on how I could improve sections of code like the below:

activate application "Final Cut Pro"
tell application "System Events"
	tell process "Final Cut Pro"
		set selectedClipNumber to 0
		set clipCounter to 1
		repeat
			try
				get selected of UI element clipCounter of UI element 1 of scroll area 1 of splitter group 1 of group 6 of splitter group 1 of window "Final Cut Pro"
				set currentClip to the result
				if currentClip then
					set selectedClipNumber to clipCounter
					exit repeat
				end if
			on error
				exit repeat
			end try
			set clipCounter to clipCounter + 1
		end repeat
		display dialog selectedClipNumber
	end tell
end tell

  1. Another issue I’ve run into is that there’s some UI elements, that I simply can’t work out how to access via UI Scripting. I’ve been using ‘UI Browser’ and ‘Accessibility Inspector’ to work out what’s what - but there seems to be a few items in FCPX that UI Browser’s Screen Reader struggles with - for example:

What do these null objects mean? How do I deal with this using AppleScript?

  1. If anyone’s really keen and interested, I would LOVE some advice on how I can improve the overall speed and efficiency of all the AppleScript I’ve thrown together (you can download the entire Hammerspoon script on the blog listed above).

Any questions let me know! Thanks in advance!

Best Regards, Chris!

Model: MacBook Pro (Retina, 15-inch, Early 2013)
AppleScript: AppleScript 2.5
Browser: Safari 601.7.7
Operating System: Other

I don’t own Final Cut (Pro or not).

You may try to use :

activate application "Final Cut Pro"
tell application "System Events"
	tell process "Final Cut Pro"
		set frontmost to true # I always do that explicitly
		set everyStatus to get selected of every UI element of UI element 1 of scroll area 1 of splitter group 1 of group 6 of splitter group 1 of window "Final Cut Pro"
		
		set selectedClipNumber to 0
		set clipCounter to 1
		repeat with aStatus in everyStatus
			set clipCounter to clipCounter + 1
			if aStatus then
				set selectedClipNumber to clipCounter
				exit repeat
			end if
		end repeat
		display dialog selectedClipNumber
	end tell
end tell

which is supposed to grab the status of every clip in a single call.
After that, it apply a loop to the list of returned values.

Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) samedi 17 septembre 2016 16:06:19

Legend, thanks so much Yvan! Very much appreciated!

I had to change “set clipCounter to 0” - but apart from that your code works perfectly!

One of the other big challenges I have with this script is that there’s so many different ways users can have the Final Cut Pro interface set up.

I’ve currently just been using a whole bunch of “try’s” to get around this, which I know is not the best way to do this.

Any suggestions on how I can improve and simplify the below? I’m assuming I can use a bunch of “whose” statements, but I haven’t been able to make it work.

I’d also still love to work out an answer to my first question in the original post, if anyone has any ideas!

Thanks in advance!


script highlightFCPXBrowserPlayhead
	--------------------------------------------------------------------------------				
	-- Error Messages:
	--------------------------------------------------------------------------------									
	set commonErrorMessageStart to "Opps! An error has occurred:" & return & return
	set commonErrorMessageEnd to return & return & "Please take a screenshot and email it to:" & return & "chris@latenitefilms.com" & return & "...so we can try and come up with a fix." & return & return & "Thank you!"
	--------------------------------------------------------------------------------									
	-- Talk to FCPX:
	--------------------------------------------------------------------------------																
	activate application "Final Cut Pro"
	tell application "System Events"
		tell process "Final Cut Pro"
			repeat with theIncrementValue from 3 to 9
				try
					get position of value indicator 1 of group 1 of scroll area 2 of splitter group 1 of group theIncrementValue of splitter group 1 of window "Final Cut Pro"
					return the result
				on error
					-- Skip Error
				end try
			end repeat
			repeat with theIncrementValue from 3 to 9
				try
					get position of value indicator 1 of group 1 of scroll area 1 of splitter group 1 of group theIncrementValue of splitter group 1 of window "Final Cut Pro"
					return the result
				on error
					-- Skip Error
				end try
			end repeat
			repeat with theIncrementValue from 3 to 9
				try
					get position of value indicator 1 of group 1 of splitter group 1 of splitter group 1 of group theIncrementValue of splitter group 1 of window "Final Cut Pro"
					return the result
				on error
					-- Skip Error
				end try
			end repeat
			try
				get position of value indicator 1 of group 1 of scroll area 1 of splitter group 1 of group 1 of splitter group 1 of window "Events"
				return the result
			on error
				-- Skip Error
			end try
			try
				get position of value indicator 1 of group 1 of scroll area 2 of splitter group 1 of group 1 of splitter group 1 of window "Events"
				return the result
			on error
				-- Skip Error
			end try
			--------------------------------------------------------------------------------													
			-- If you get to here something went wrong:
			--------------------------------------------------------------------------------													
			display dialog commonErrorMessageStart & "Unable to locate the Browser Playhead." & commonErrorMessageEnd buttons {"Close"} with icon caution
			return "failed"
		end tell
	end tell
end script
run script highlightFCPXBrowserPlayhead

Based on what I learnt from your example Yvan, I’ve had a go at re-writing this section of the script without using all the “try” statements.

I think it’s probably a lot cleaner and less error-prone, but it still suffers from the big issue of if there’s lots of items in the Final Cut Pro browser it runs incredibly slow. I’m also not sure that it’s actually any faster than what I had originally, which is annoying.

If anyone has any suggestions on how I could improve performance, let me know. Thank you!


script highlightFCPXBrowserPlayhead
	--------------------------------------------------------------------------------				
	-- Error Messages:
	--------------------------------------------------------------------------------	
	set macOSVersion to system version of (system info)
	set fcpVersion to version of application "Final Cut Pro"
	set commonErrorMessageStart to "I'm sorry, but the following error has occurred:" & return & return
	set commonErrorMessageEnd to return & return & "macOS Version: " & macOSVersion & return & "FCP Version: " & fcpVersion & return & return & "Please take a screenshot of your entire screen and email it to the below address so that we can try and come up with a fix:" & return & return & "chris@latenitefilms.com" & return & return & "Thank you for testing!"
	
	--------------------------------------------------------------------------------									
	-- Talk to FCPX:
	--------------------------------------------------------------------------------																
	activate application "Final Cut Pro"
	tell application "System Events"
		tell process "Final Cut Pro"
			set frontmost to true
			if window "Events" exists then
				--------------------------------------------------------------------------------	
				-- Using Second Monitor:
				--------------------------------------------------------------------------------					
				if group 1 of splitter group 1 of splitter group 1 of group 1 of splitter group 1 of window "Events" exists then
					--------------------------------------------------------------------------------	
					-- List View:
					--------------------------------------------------------------------------------	
					if value indicator 1 of group 1 of splitter group 1 of splitter group 1 of group 1 of splitter group 1 of window "Events" exists then
						get position of value indicator 1 of group 1 of splitter group 1 of splitter group 1 of group 1 of splitter group 1 of window "Events"
						return the result
					end if
				else
					--------------------------------------------------------------------------------	
					-- Filmstrip View:
					--------------------------------------------------------------------------------	
					if value indicator 1 of group 1 of last scroll area of splitter group 1 of group 1 of splitter group 1 of window "Events" exists then
						get position of value indicator 1 of group 1 of last scroll area of splitter group 1 of group 1 of splitter group 1 of window "Events"
						return the result
					end if
				end if
			else
				--------------------------------------------------------------------------------	
				-- Using Single Monitor:
				--------------------------------------------------------------------------------	
				set selectedGroup to 0
				repeat with currentGroup from 1 to (count of groups of splitter group 1 of window "Final Cut Pro")
					if group 1 of last scroll area of splitter group 1 of group currentGroup of splitter group 1 of window "Final Cut Pro" exists then
						set selectedGroup to currentGroup
						exit repeat
					else if group 1 of splitter group 1 of splitter group 1 of group currentGroup of splitter group 1 of window "Final Cut Pro" exists then
						set selectedGroup to currentGroup
						exit repeat
					end if
				end repeat
				if selectedGroup is not 0 then
					if group 1 of splitter group 1 of splitter group 1 of group selectedGroup of splitter group 1 of window "Final Cut Pro" exists then
						--------------------------------------------------------------------------------	
						-- List View:
						--------------------------------------------------------------------------------	
						if value indicator 1 of group 1 of splitter group 1 of splitter group 1 of group selectedGroup of splitter group 1 of window "Final Cut Pro" exists then
							get position of value indicator 1 of group 1 of splitter group 1 of splitter group 1 of group selectedGroup of splitter group 1 of window "Final Cut Pro"
							return the result
						end if
					else
						--------------------------------------------------------------------------------	
						-- Filmstrip View:
						--------------------------------------------------------------------------------
						if value indicator 1 of group 1 of last scroll area of splitter group 1 of group selectedGroup of splitter group 1 of window "Final Cut Pro" exists then
							get position of value indicator 1 of group 1 of last scroll area of splitter group 1 of group selectedGroup of splitter group 1 of window "Final Cut Pro"
							return the result
						end if
					end if
				end if
			end if
			--------------------------------------------------------------------------------													
			-- If you get to here something went wrong:
			--------------------------------------------------------------------------------													
			display dialog commonErrorMessageStart & "Unable to locate the Browser Playhead." & commonErrorMessageEnd buttons {"Close"} with icon caution
			return "failed"
		end tell
	end tell
end script
run script highlightFCPXBrowserPlayhead

As I wrote, I don’t own FCP.

I’m wondering if you may find an other object allowing you to test the used mode.
Maybe there is a difference in a menu item according to the status List View / Film Strip View

Maybe there is a difference too in a menu according to the status use 2nd monitor / use 1st monitor
If such differences exist, you may build your tests upon them.

About you first question, if you are grabbing the value from a single item, I don’t know what would help to reduce the execution time except perhaps if, the relevant data may be reflected in a menu item.

Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) dimanche 18 septembre 2016 09:30:22

That’s an awesome idea Yvan! It didn’t even cross my mind to use menu items to work out the screen layout. Thank you! I’ll give it a try shortly and see if it speeds things up a tad.

Unfortunately however in regards to question one, there’s no menu items that can help. Ignoring Final Cut Pro, I can reproduce the same issue with Finder. If I have a Finder window with THOUSANDS of files displayed - UI Browser grinds to a halt. If there’s only a few hundred files, then it works fine. It seems the more “things” you have, the slower the UI Scripting seems to work. If anyone has any ideas of how to workaround, let me know.

Thanks again Yvan!

Sorry another question…

Assuming I can’t solve the speed issue… is there anyway I can put a timeout on a “get” function?

I tried:


with timeout of 10 seconds
get value of attribute "AXSelectedChildren" of group groupCounter of group 1 of last scroll area of splitter group 1 of group selectedGroup of splitter group 1 of window whichWindow
end timeout

…but it didn’t work. Any suggestions?

For anyone who’s interested, below is the latest versions of the scripts I’m messing around with.

Unfortunately, I still haven’t been able to solve the “slowness” issue with big Final Cut Pro projects.

You can also download the complete Hammerspoon script here: https://latenitefilms.com/blog/final-cut-pro-enhanced-match-frame/

If anyone has any suggestions on how to improve to below code, let me know!

Thanks in advance!

Single Match Frame:


script talkToFCPX
	--------------------------------------------------------------------------------				
	-- Error Messages:
	--------------------------------------------------------------------------------									
	set scriptVersion to "1.9"
	set macOSVersion to system version of (system info)
	set fcpVersion to version of application "Final Cut Pro"
	set commonErrorMessageStart to "I'm sorry, but the following error has occurred:" & return & return
	set commonErrorMessageEnd to return & return & "macOS Version: " & macOSVersion & return & "FCP Version: " & fcpVersion & return & "Script Version: " & scriptVersion & return & return & "Please take a screenshot of your entire screen and email it to the below address so that we can try and come up with a fix:" & return & return & "chris@latenitefilms.com" & return & return & "Thank you for testing!"
	--------------------------------------------------------------------------------						
	-- Talk to FCPX:
	--------------------------------------------------------------------------------		    
	activate application "Final Cut Pro"
	tell application "System Events"
		tell process "Final Cut Pro"
			set frontmost to true
			set whichWindow to ""
			--------------------------------------------------------------------------------				
			-- Switch to Thumbnail View:
			--------------------------------------------------------------------------------	
			try
				perform action "AXPress" of menu item "as Filmstrips " of menu 1 of menu item "Browser" of menu 1 of menu bar item "View" of menu bar 1
			on error
				display dialog commonErrorMessageStart & "Failed to Switch to Thumbnail View." & commonErrorMessageEnd buttons {"Close"} with icon caution
				return "failed"
			end try
			--------------------------------------------------------------------------------				
			-- Set Thumbnail Duration to All:
			--------------------------------------------------------------------------------
			set thumbnailDurationToAllStatus to false
			if window "Events" exists then
				--------------------------------------------------------------------------------	
				-- Using Second Monitor:
				--------------------------------------------------------------------------------					
				set whichWindow to "Events"
				set selectedGroup to 1
				if value indicator 1 of slider 1 of group 2 of group 1 of splitter group 1 of window "Events" exists then
					set value of value indicator 1 of slider 1 of group 2 of group 1 of splitter group 1 of window "Events" to 0
					set thumbnailDurationToAllStatus to true
				end if
			else
				--------------------------------------------------------------------------------	
				-- Using Single Monitor:
				--------------------------------------------------------------------------------				
				set whichWindow to "Final Cut Pro"
				set selectedGroup to 0
				repeat with currentGroup from 1 to (count of groups of splitter group 1 of window "Final Cut Pro")
					if group 1 of last scroll area of splitter group 1 of group currentGroup of splitter group 1 of window "Final Cut Pro" exists then
						set selectedGroup to currentGroup
						exit repeat
					else if group 1 of splitter group 1 of splitter group 1 of group currentGroup of splitter group 1 of window "Final Cut Pro" exists then
						set selectedGroup to currentGroup
						exit repeat
					end if
				end repeat
				if value indicator 1 of slider 1 of group 2 of group selectedGroup of splitter group 1 of window "Final Cut Pro" exists then
					set value of value indicator 1 of slider 1 of group 2 of group selectedGroup of splitter group 1 of window "Final Cut Pro" to 0
					set thumbnailDurationToAllStatus to true
				end if
			end if
			if thumbnailDurationToAllStatus is false then
				display dialog commonErrorMessageStart & "Failed to Set Thumbnail Duration to All." & commonErrorMessageEnd buttons {"Close"} with icon caution
				return "failed"
			end if
			--------------------------------------------------------------------------------				
			-- Make sure timeline is active:
			--------------------------------------------------------------------------------				
			try
				perform action "AXPress" of menu item "Timeline" of menu 1 of menu item "Go To" of menu 1 of menu bar item "Window" of menu bar 1
			on error
				display dialog commonErrorMessageStart & "Failed to make timeline active." & commonErrorMessageEnd buttons {"Close"} with icon caution
				return "failed"
			end try
			--------------------------------------------------------------------------------				
			-- Trigger 'Reveal in Browser':
			--------------------------------------------------------------------------------
			try
				click menu item "Reveal in Browser" of menu 1 of menu bar item "File" of menu bar 1
			on error
				display dialog commonErrorMessageStart & "Failed to Reveal in Browser." & commonErrorMessageEnd buttons {"Close"} with icon caution
				return "failed"
			end try
			--------------------------------------------------------------------------------
			-- Find Selected Clip Number:
			--------------------------------------------------------------------------------
			set selectedClipNumber to 0
			set groupCounter to 1
			repeat
				try
					get value of attribute "AXSelectedChildren" of group groupCounter of group 1 of last scroll area of splitter group 1 of group selectedGroup of splitter group 1 of window whichWindow
					set selectedChildren to the result
					if selectedChildren as string is not equal to "" then
						set selectedClipNumber to groupCounter
						exit repeat
					end if
				on error
					exit repeat
				end try
				set groupCounter to groupCounter + 1
			end repeat
			if selectedClipNumber is 0 then
				display dialog commonErrorMessageStart & "Failed to find which group number our match frame belongs to." & commonErrorMessageEnd buttons {"Close"} with icon caution
				return "failed"
			end if
			--------------------------------------------------------------------------------
			-- Get text from the selected clip:
			--------------------------------------------------------------------------------						      		      
			try
				get value of text field 1 of group selectedClipNumber of group 1 of last scroll area of splitter group 1 of group selectedGroup of splitter group 1 of window whichWindow
				set titleOfSelectedClip to the result
			on error
				display dialog commonErrorMessageStart & "Failed to get the title of the selected clip." & commonErrorMessageEnd buttons {"Close"} with icon caution
				return "failed"
			end try
			--------------------------------------------------------------------------------
			-- Set the search field to Title of the Selected Clip:
			--------------------------------------------------------------------------------						
			try
				set value of text field 1 of group 1 of group selectedGroup of splitter group 1 of window whichWindow to titleOfSelectedClip
			on error
				display dialog commonErrorMessageStart & "Failed to enter the search text." & commonErrorMessageEnd buttons {"Close"} with icon caution
				return "failed"
			end try
			--------------------------------------------------------------------------------
			-- Run the search in FCPX:
			--------------------------------------------------------------------------------
			try
				perform action "AXConfirm" of text field 1 of group 1 of group selectedGroup of splitter group 1 of window whichWindow
			on error
				display dialog commonErrorMessageStart & "Failed to trigger the search command." & commonErrorMessageEnd buttons {"Close"} with icon caution
				return "failed"
			end try
			--------------------------------------------------------------------------------
			-- Completed!
			--------------------------------------------------------------------------------
			return "done"
		end tell
	end tell
end script
run script talkToFCPX

Highlight Browser Playhead:


script highlightFCPXBrowserPlayhead
	--------------------------------------------------------------------------------				
	-- Error Messages:
	--------------------------------------------------------------------------------	
	set scriptVersion to "1.9"
	set macOSVersion to system version of (system info)
	set fcpVersion to version of application "Final Cut Pro"
	set commonErrorMessageStart to "I'm sorry, but the following error has occurred:" & return & return
	set commonErrorMessageEnd to return & return & "macOS Version: " & macOSVersion & return & "FCP Version: " & fcpVersion & return & "Script Version: " & scriptVersion & return & return & "Please take a screenshot of your entire screen and email it to the below address so that we can try and come up with a fix:" & return & return & "chris@latenitefilms.com" & return & return & "Thank you for testing!"
	--------------------------------------------------------------------------------									
	-- Talk to FCPX:
	--------------------------------------------------------------------------------																
	activate application "Final Cut Pro"
	tell application "System Events"
		tell process "Final Cut Pro"
			set frontmost to true
			if window "Events" exists then
				--------------------------------------------------------------------------------	
				-- Using Second Monitor:
				--------------------------------------------------------------------------------					
				if group 1 of splitter group 1 of splitter group 1 of group 1 of splitter group 1 of window "Events" exists then
					--------------------------------------------------------------------------------	
					-- List View:
					--------------------------------------------------------------------------------	
					if value indicator 1 of group 1 of splitter group 1 of splitter group 1 of group 1 of splitter group 1 of window "Events" exists then
						get position of value indicator 1 of group 1 of splitter group 1 of splitter group 1 of group 1 of splitter group 1 of window "Events"
						return the result
					end if
				else
					--------------------------------------------------------------------------------	
					-- Filmstrip View:
					--------------------------------------------------------------------------------	
					if value indicator 1 of group 1 of last scroll area of splitter group 1 of group 1 of splitter group 1 of window "Events" exists then
						get position of value indicator 1 of group 1 of last scroll area of splitter group 1 of group 1 of splitter group 1 of window "Events"
						return the result
					end if
				end if
			else
				--------------------------------------------------------------------------------	
				-- Using Single Monitor:
				--------------------------------------------------------------------------------	
				set selectedGroup to 0
				repeat with currentGroup from 1 to (count of groups of splitter group 1 of window "Final Cut Pro")
					if group 1 of last scroll area of splitter group 1 of group currentGroup of splitter group 1 of window "Final Cut Pro" exists then
						set selectedGroup to currentGroup
						exit repeat
					else if group 1 of splitter group 1 of splitter group 1 of group currentGroup of splitter group 1 of window "Final Cut Pro" exists then
						set selectedGroup to currentGroup
						exit repeat
					end if
				end repeat
				if selectedGroup is not 0 then
					if group 1 of splitter group 1 of splitter group 1 of group selectedGroup of splitter group 1 of window "Final Cut Pro" exists then
						--------------------------------------------------------------------------------	
						-- List View:
						--------------------------------------------------------------------------------	
						if value indicator 1 of group 1 of splitter group 1 of splitter group 1 of group selectedGroup of splitter group 1 of window "Final Cut Pro" exists then
							get position of value indicator 1 of group 1 of splitter group 1 of splitter group 1 of group selectedGroup of splitter group 1 of window "Final Cut Pro"
							return the result
						end if
					else
						--------------------------------------------------------------------------------	
						-- Filmstrip View:
						--------------------------------------------------------------------------------
						if value indicator 1 of group 1 of last scroll area of splitter group 1 of group selectedGroup of splitter group 1 of window "Final Cut Pro" exists then
							get position of value indicator 1 of group 1 of last scroll area of splitter group 1 of group selectedGroup of splitter group 1 of window "Final Cut Pro"
							return the result
						end if
					end if
				end if
			end if
			--------------------------------------------------------------------------------													
			-- If you get to here something went wrong:
			--------------------------------------------------------------------------------													
			display dialog commonErrorMessageStart & "Unable to locate the Browser Playhead." & commonErrorMessageEnd buttons {"Close"} with icon caution
			return "failed"
		end tell
	end tell
end script
run script highlightFCPXBrowserPlayhead

Match Frame Then Highlight Browser Playhead:


script matchFrameThenHighlightFCPXBrowserPlayhead
	--------------------------------------------------------------------------------				
	-- Error Messages:
	--------------------------------------------------------------------------------									
	set scriptVersion to "1.9"
	set macOSVersion to system version of (system info)
	set fcpVersion to version of application "Final Cut Pro"
	set commonErrorMessageStart to "I'm sorry, but the following error has occurred:" & return & return
	set commonErrorMessageEnd to return & return & "macOS Version: " & macOSVersion & return & "FCP Version: " & fcpVersion & return & "Script Version: " & scriptVersion & return & return & "Please take a screenshot of your entire screen and email it to the below address so that we can try and come up with a fix:" & return & return & "chris@latenitefilms.com" & return & return & "Thank you for testing!"
	--------------------------------------------------------------------------------									
	-- Talk to FCPX:
	--------------------------------------------------------------------------------															    
	activate application "Final Cut Pro"
	tell application "System Events"
		tell process "Final Cut Pro"
			set frontmost to true
			try
				--------------------------------------------------------------------------------
				-- Reveal in Browser:
				--------------------------------------------------------------------------------						
				click menu item "Reveal in Browser" of menu 1 of menu bar item "File" of menu bar 1
			on error
				display dialog commonErrorMessageStart & "Unable to trigger Reveal in Browser." & commonErrorMessageEnd buttons {"Close"} with icon caution
				return "failed"
			end try
		end tell
	end tell
end script
run script matchFrameThenHighlightFCPXBrowserPlayhead

For anyone who’s interested, I’ve been chatting with Bill Cheeseman over at PFiddlesoft (pfiddlesoft.com), who make UI Browser, and he had some really interesting things to say (reproduced with his permission).

In regards to question one:

If anyone has any ideas if you can actually pull this off using AppleScript, let me know!

In regards to question three: