#Break UI Automation tasks into granular sub-macros
I'll make this short-ish and to the point. I may post other lessons, but I think this specific hard-earned lesson should be shared.
I use Final Cut Pro X (FCPX) a lot, and I built a lot of KM automation macros to make things easier. Apple recently released a new version of FCPX, and a lot of my macros broke. And I earned an important lesson, which I'll share here.
The lesson is this: Place every single bit of automation in its own sub-macro, so there's only one place to change things.
Here's an example of something that changed in FCPX: You used to be able to select a clip in the timeline, press ⇧F, and FCPX would find the clip in the browser, and set focus to the browser window.
It's just one keystroke, right?
So I just repeated this action anywhere I needed it.
But now, while ⇧F still finds the clip in the browser, it no longer sets the focus to the browser window, which broke a bunch of things. So now I have to find everywhere I simulated ⇧F, and change it.
##Here's what I should have done:
When I simulated the ⇧F keystroke, what I really wanted to happen was "Find" and then "Focus". So now I have these macros:
So now, instead of using
I use this:
Which leaves me with only one or two places I have to change, if something breaks.
###So here's what I've got so far, but of course I have a long way to go:
So that's my recommendation to everyone who automates UIs. Break tasks into very small chunks, and make sub-macros for everything.
###You might want to get this macro, if you don't already have it:
This makes it easy to select one of the aforementioned sub-macros, then paste in an "Execute a Macro" action that calls the sub-macro.