In Leopard, Apple introduced AMWorkflowView
and AMWorkflowController
, which let you easily add automator-editing capabilities to your application (modulo bugs!)
Obviously, for editing a workflow to be useful, you need to be able to add actions to it. And to do that, you need to be able to browse and search actions. But the current Automator.framework has no official support for doing this.
But there are undocumented private APIs, which Automator.app (link launches it) uses…
How to Find Them
class-dump is an amazingly useful command-line tool that lets you generate headers from a compiled Objective-C binary. Download it, and point it at /System/Library/Frameworks/Automator.framework/Automator
, to see everything Automator.framework really lets you do.
Instant Library Panel
The most useful definition I found was,
@interface NSApplication (AMLibraryPanel)
- (void)orderFrontAutomatorLibraryPanel:(id)sender;
@end
Calling [NSApp orderFrontAutomatorLibraryPanel:nil];
will show a panel with the same action-library view Automator has.
This is what I’m using right now in IMLocation to let people find actions for workflows. I don’t like the idea of using private APIs. But I like the idea of implementing my own AMLibraryView
replacement even less. It would be a lot of work to make it as good as the real thing. Any differences give users a fractured experience — one way to do something in Automator, another in my program. And I would get dismal ROI, because I expect Apple to expose this functionality in the (near) future.
(I also wouldn’t be so bullish on using private APIs if I didn’t have workarounds in place right now. The only way orderFrontAutomatorLibraryPanel:
gets called is if a user presses a “Show Actions” button on the toolbar. That same toolbar has an “Open in Automator” button that opens the worklfow in Automator, where they can edit it without bugs. So even if orderFrontAutomatorLibraryPanel:
stopped working tomorrow, users could still do everything they could before — albeit less elegantly).
Looking Just Like Automator
I don’t recommend doing this, but I’ve been able to embed an AMLibraryView
in an NSSplitView
next to an AMWorkflowView
, to get a more Automator.app-like appearance.
Here’s how I did it, given the IBOutlet
s workflowViewAndLibrarySplitView
which is an NSSplit
view with an AMWorkflowView
in one side, and the other side’s view connected to the outlet workflowLibraryView
,
[workflowViewAndLibrarySplitView replaceSubview:workflowLibraryView with:[[AMLibraryPanel sharedLibraryPanel] _libraryView]];
Will put the library view inside your split view.
Of course this screws up orderFrontAutomatorLibraryPanel:
. And I would not expect it to work in two windows. And it’s using an underscore-private method of an already private and undocumented API. That’s just to too risky for me; so I stick with the panel. It gets the job done with one line of code, and that’s good enough for me.