Pimp my workflow: 1. Swiping icons for your Automator apps.
10/30/05 04:30 AM
It's not that Automator's standard icons for workflows and apps look boring after creating so many workflows. It's just that they're not distinctive enough to easily find. These standard icons are important visual cues, since we depend on the visual for quick reference. They tell us what kind of file a workflow is, but when you have 5 Automator apps on your dock, forget it. You can't remember which is which. This is where distinctive icons really help out.
You can copy any icon on your mac and use it as an icon for your workflows and apps. These aren't really custom, but they can be much more recognizable than the standard icons. Here's how to do it. All you're doing is copying and pasting a reference to the icon.
From the Finder, click once on an icon that you want to swipe.
Click Apple-i
Click on the icon on the top left of the info screen.
Click Apple-C
From the Finder, click once on the icon of the workflow or app you want to replace.
Click Apple-i
Click on the icon on the top left of the info screen.
Click Apple-V
Here it may seem this cumbersome, but once you have the hang of it, it's a very intuitive process. The one issue is that if you resave an app or workflow, the standard icon is back. You'll just have to paste it again. Later, I'll cover cheap and simple ways to create your own icons.
The other issue is that this method only make the switch on your machine. If you share the app it will have the standard Automator app icon on other machines. It appears can can't get a custom icon to be included within a shared workflow...but you can put a custom icon in an Automator app. More in the next episode of Pimp my workflow.Creating nested Folders.
10/21/05 04:15 PM
Creating new nested folders can be done with Automator and a little trickery. Here's the action:

The EscherSketch here is that that folder called "Folder" doesn't exist until the workflow is run, so you can't call up a folder that doesn't exist in the last three actions. The trick is to create a new folder called "Folder" on the desktop, call it up in the necessary actions and then delete it. Having the reference to it and its location is all Automator wants.
You can add a Move Finder Items action afterwards to move this where you like. But it must be created in a defined location, like the Desktop or Hard Drive, before moving it. You can also extend this structure, either by creating an action for each folder needed or by using Copy Finder Items and Rename Finder Items actions to put folders full of folders inside folders full of folders.
You can custom name folders in each workflow by using the option: Show workflow when run. Don't to offer to much leeway or you'll wind up having to click return for the creation of each folder.
Summoning ghost files.
10/21/05 06:28 AM
Writing Automator workflows is sometimes plagued by the problem of calling up a specific file that won't exist until an earlier part of the workflow has been run. So if a workflow creates a file called "imagetmp.jpg", the image has to exist before you can reference it later in the workflow. It can't be listed in the Get Specified Finder Items action while you're writing the workflow because it doesn't exist yet.
This Catch 22 has a simple workaround: Rename a file "imagetmp.jpg", put it where you want Automator to look for it. Then use the reference to it in the Get Specified Finder Items action. You can delete the file once you have the reference to it in the workflow. Automator has the name of the file to be created, even when it doesn't exist yet. It will rewrite over the file each time the workflow is run.
Otto's Stash: Where Otto hides your files.
10/17/05 12:57 PM
Many times Otto works with covertly with files. Probably the most obvious is when a PDF is created. Use most any of the PDF actions and you'll be quickly confused because the files you make look don't seem to exist. Otto keeps these in a private folder that Spotlight can't see. What good does this do for us if we don't have normal access to the files? Fortunately Automator keeps a reference to these files.
So if you call up the Watermark PDF action, follow it with Move Finder Items and set the location as the desktop. Now when you run the workflow, the file will appear on the desktop as a PDF with gibberish for a name. If you add a Rename Finder Items action to the workflow, you can assign it a less-random name.
So where is Otto's hiding place? It's a good idea to check it every once and a while to make sure you haven't filled it will a billion files in your workflow experiments that you thought weren't working. To view the folder from the Finder, click the Go menu, choose Go to Folder and then type
/private/tmp. Most likely it's safe to dump any files in here in the trash.
Getting Automator to jump through loops.
10/13/05 10:54 AM
The loop: the basic unit of a computer program, is something Automator can't do, or can it? Automator can in fact do loops.
This one is useless, but it works. The workflow asks the user if they want to run it, runs it, and then runs itself. Since I haven't figured out a way to create an "until" statement in Automator to keep the loop from running forever, this one gives the user an out by asking if they want to run it again. The "action" of this loop is an inaction: it just pauses for a second. The Pause action could be replaced with the meat of a workflow. Don't know what you'd do with it. But as Einstein said: "I just came up with a simple formula to release untold energy. You guys in the Manhattan Project want to see if it's worth looking into?"
There are a few tricks to getting this to work. The Run Workflow list will not contain the Loop workflow. Save the workflow before you add the actions. Call the workflow up in the Run Workflow action by clicking on Other and call it up from it's location. Then save it again. Before running, it's a good idea to exit Automator and restart holding down the option key to clear the cache.
Much happy fusion to you.Poor traveling companion.
10/10/05 03:57 PM
Automator is the programming environment I've been waiting for. It's simple, quick and easy. I can throw together an app idea in a few minutes, and email a working copy to a friend.
But there's a problem with portability: to use any action, it must be installed on the computer the app is run on. So if you have a horde of 3rd party actions you use in your workflows, they won't work on another Mac unless all the actions are installed on that computer. And as we all know, installing actions is beyond the comfort level of the casual Mac user. An though the actions that come built into Automator are extensive, your workflows become limited without the extras. So Automator workflows don't travel well. Sad that Apple didn't rig Automator apps so they could have these action compiled with them. But it's really an intellectual property issue, not a technical issue. And after all Automator is primarily a personal programming environment.
So what can we do about it? You could use AppleScript to create an installer that would install the actions as well as your app. But this is almost as much work and requires as much coding as writing an XCode app. The easier option is to find AppleScript snippets that mimic these actions. Written AppleScript is contained within the Run Applescript actions in the workflow or app itself.
Some of the 3rd party actions available are so simple they can be mimicked in a few lines of code. You can control click on the actions themselves to show the package contents and possibly see the code that was used. But most developers compile this into machine code that can't be interpreted. (Some of the extra actions that Apple has created are readable.) Fortunately there's a huge number of AppleScripts on the Web that you can learn from and modify for your needs.
UI scripting is an extension of AppleScript that allows you to control apps much the way Automator does and allows you access to menu commands in most apps. UI scripting puts a huge amount of programming power in a few simple lines of code that most anyone can figure out without learning AppleScript. Here's one I figured out: tell application "System Events"
tell application "Stickies" to activate
tell process "Stickies" to keystroke "v" using command down
end tell
Paste this into the Run Applescript action you'll find in the Automator library. Click run and this will popup a new Sticky note and paste whatever's on the clipboard in it. Great. But there's one problem: any time you see System Events in AppleScript UI scripting needs to be turned on. UI scripting is off by default. Most likely there's an AppleScript or Shell script that can do that, but it's well beyond my skill. Here's a workaround I modified from a script I found on the Bayport NY Fire Department site:
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "Make sure \"Enable access for assistive devices\" is checked for this app to run"
end tell
This gem calls up the Universal Access pane in Preferences and flashes a dialog that tells the user to make sure the box that enables UI scripting is checked to run the app. This can be inserted into a Run AppleScript action, then saved as an app called "Double Click to Setup the Application." It's easy and you didn't trespass into anyone's system to do it. It's already compiled as an app here.
I'm compiling a compendium of simple scriptlets that will make applications and workflows more portable. Feel free to send me any you come up with that you'd like to share.