WWDC2004 Session 303
Transcript
Kind: captions
Language: en
ladies and gentlemen please welcome Todd
Fernandez good morning welcome to
session 303 developing for automator as
I was just introduced on Todd Fernando's
the Automator engineering manager and
I'm thrilled to be here with you this
morning representing the Automator team
to tell you what you need to know about
about how to take advantage of this
exciting new technology for your
applications so what I hope you take
away from this session this morning is a
much better understanding of what
automator is including its key features
and terminology why it's important to
you and most importantly how you can
take advantage of applicant is new
technology for your applications will
cover the SDK and design guidelines to
help you so I would like to set the
stage a little bit by first talking
about what things were like before
yesterday with current technology it's
been very difficult to take advantage
and exploit powerful network effects of
combining disparate applications into
automated workflows it's been possible
with with technology like Apple script
but the problem has been that it
requires a relatively large investment
of time and resources to develop the
necessary expertise small business and
the vast majority of end users have not
been able to take advantage of this
power
excuse me
and in fact even those of us that have
the necessary expertise sometimes have
to make the calculation is it going to
take me longer to write and debug a
script or to just do what I need to do
by hand well fortunately automator
fundamentally changes this calculation
and dramatically lowers the bar for
automating tasks on Mac OS 10 now you
can you don't need a map you don't need
an expert guide that guru colleague or
precocious nephew to help you make the
connection is to get your data from the
application a to application be for the
first time end users can seamlessly
extend and combine applications on their
own and in fact once developers of
complex and powerful applications start
exposing their application technology
through Automator users will be able to
take advantage of applications they
never could before automator allows
customers to take advantage of the best
that every application has to offer for
their benefit now this is where you come
in I recently learned how to surf and
know you can tell from that awkward
little leap that I still have a lot to
learn about surfing I did I do remember
one important lesson from my instructor
and that is when a great wave comes
you'd better catch it because you don't
know when the next one is going to come
this is a unique opportunity for you to
attract new customers to your
applications by allowing them to
incorporate your application into
Automator workflows what we've seen with
Apple script is that once that customer
incorporates your application into an
automated workflow they remain loyal
they do not want to have to go back and
do things by hand and for existing
customers automator is a breakthrough
and they are going to expect their
favorite applications work well with it
if they don't they're going to be forced
to look for third-party solutions or if
they have the necessary development or
scripting expertise to develop their own
Automator actions the problem for you is
that then you lose control over how your
technology is presented and defined so
I'd like to encourage you to get in
front of the curve catch the wave and
get to the beach as soon as you can so
we've been talking at a very high level
I'd like to come back to tourists and
talking a little bit more detail about
what Automator is well first we're
calling it up put your your own personal
automation assistant and what it
consists of are four main pieces an
application to create workflows a large
set of pre-built actions that you can
use to create those workflows tools to
create new workflows this is where you
come in and a set of examples of both
actions and workflows so it we've been
throwing around words here actions
workflows automator and I expected some
of you who have installed the tiger seed
DVD may be puzzled and disappointed that
Automator isn't there well I have a
confession to make in fact it is there
it just is called pipeline so in fact it
is there for you to start working with
and I've been talking about actions and
workflows and there are a couple of
other changes like that which I'll come
on to in a moment specifically an action
so we can define it for everyone so you
have a productive conversation it's a
discreet bit of functionality this is
what developers and scripters will
create and what customers will use to
build their workflows an example a very
simple example that many people will
need to use for their workflows is copy
files it takes input files and copies
them to a new location now here is where
we come into one of the additional
terminologies there also in various
places as you'll see during my
presentation refer to actions as stages
and that currently is mostly on the
developer side but we will certainly be
unifying on a single term for this
concept so where do users get actions
well first of all we have over 120 in
the tiger seed today and we plan to have
quite a few more by the time we ship
tiger some users will be able to create
their own and finally we get to where
you come in we we hope that third
parties will create their own set of
actions for their own applications you
know your application best and can
create a rich set of actions for your
customers to take advantage of and
attract new customers so a workflow is
composed of actions this is what users
will create themselves and here is a
relatively simple example I might want
to email to the members of my address
book
family a new archive of a copy of every
image with keyword family crops fifteen
percent and sepia filtered now you can
think about how long that would take you
to do manually especially for more than
a handful of pictures but with Automator
is very simple and I'll just point out
the fact that the copy files example
action I mentioned a couple of slides
ago appears here is one of the actions
in this workflow and in fact this
workflow is composed of six actions
which are highlighted in color so you
can get an idea of how they break down
so now I'd like to give you a little
tour of the Automator interface you saw
some of it yesterday in the keynote and
in the developer tools overview I'd like
to show you a little bit more here's a
new document you can see the filter to
action list this is the list of actions
that the user building a workflow can
select from and it's controlled by the
search field and the the category action
category is filtering above I've already
mentioned the search field that allows
you to further filter the category
actions from the category you have
selected and this we view control we
didn't show yesterday but this allows
you to switch between the cat filtering
by category and filtering by keyword
here we're showing example of selecting
the change and name keywords which then
shows us in the filtered action lists
list of actions having to do with
changing file names so again the area to
the right is where you actually
construct your workflow and I just like
to step us through building a simple
example we're going to start off finding
files and in fact this action takes
advantage of the great new spotlight
technology you heard about yesterday to
find files on my computer and I'm
looking for files with icon in the name
and that art if so I find a bunch of
files now I want to scale these images
to a common size but what happens when I
try to add the scale images action to my
workflow is I get a warning from
automator letting me know that this
action can change the data that's being
passed into it and asked me if I'd like
to actually copy them first and add a
copy file to action so I'm working on
with the copies and not the originals so
I'm going to say yes I want to add that
too
and now I've got three actions in my
workflow and I'm scaling each image
passed to the scale images action to 480
pixels next let's let's use some fancy
quartz technology let's let's apply a
blue filter and let's see then we're
going to convert those tips to jpg and
then we want to import them into iphoto
and indicated here is once I built my
workflow I can easily click the Run
button to execute it and once I've built
and tested my workflow I can save it I
can save it as a workflow document and
in that case i can either reopen an
automator and run it from the tool
itself or i can save it the scripts menu
to run from there the other choice is to
save it as an application this opens
once a lot of additional opportunities
first of all then it can be double
clicked and launched from finder but it
can also be used as a droplet you can
then drop files on to feed the beginning
of your workflow and still more you can
actually attach a workflow application
as an alarm in iCal so you can schedule
the execution of your workflows and one
more little tidbit if you use image
capture to download your digital photos
from your digital camera you can
actually tell image capture to launch an
application when it's done it
downloading your photos which allows you
to build in an image processing work
flow right in an image capture so that's
our little tour of the automator
interface now I like to give you a brief
demo of creating a workflow you switch
to demo one and what I'd like to do
since this is a developer conference to
show you something that's focused on
developers needs now we in the automator
team have over 120 action projects and
while you may not have that many
projects through application although
you may I'm sure you have enough that
you don't like to do things manually
with them automator can help you
eliminate a lot of the drudgery in your
development life and it really has for
us we've used various automated
workflows as we've developed the
application to simplify our lives one
very similar to what I'm going to show
you today and another that through most
of our development license of Automator
we've used to build the project to start
with the Xcode project files bump the
version
build the project's package them up and
attach the packet the Mac os10 package
to a new email to the project team to
send out routes every time we do a new
build this is just one simple example of
how automator can simplify your life so
what I want to do do for you today is
show you yet another feature we've got a
contextual menu in finder which allows
you to start building work flows
directly from finder so I don't want to
show you a hundred twenty projects I've
just got three here for an example and
what I want to do is build so let's
switch over the keyword keyword
interface just to show you that and i'm
going to select the right keyword this
time drag over build the build xcode
project action and let's see i just want
to do a clean build and then finally i
want to capture the build results in a
new text edit document so alright let's
go ahead and try running that workflow
so as you can see each actions marked
with a green check to let you know that
it's completed successfully now we're
building the projects and here are
billed results great so we've we built
our three projects but what I want to do
is and go back to Automator and save our
workflow it's going to be using this
throughout our demos today and let's see
build projects alright and what I want
to do now is go back and look at our
build and see what we've got here so
here I'd like to explain that an
automator action is a standard mac OS 10
bundl it has the same contents that
you'd expect contents resources and
we've got a script folder here this
action is built using applescript so you
can use other development languages
which will get will show you during the
session and I want to look in the main
script and oh that's a problem I don't
want to ship the source of my action to
my users I need to strip that out the
problem is I don't have an action to set
a new build setting an Xcode but in fact
i will show you how to do that in a
moment
so can we go back to slides please so
I'll show you a very simple workflow
just three actions but I've already
found a hole in my workflow I want to
build the projects but they're not
building the way I want and I don't want
to have to go through three is one thing
you can open each up in Xcode manually
add the new build setting close it again
but for 120 you do not want to do that
manually but I've now got a hole in my
workflow so how do i fill that in well
the easiest way is to just do it right
there in Automator you can add a run
script action which allows you to enter
whatever Apple script you you need to do
what the action needs to do right there
in the interface and you can use this as
an easy way to prototype a new action
once you've done that and tested it and
seeing that if useful to you you may
then want to turn it into a
fully-fledged fully-fledged automator
action and to do that you create a new
Xcode project and here again we get into
the the naming issue there are two
templates in the seed that you have
there's one for creating an app Apple
script pipeline stage otherwise known as
an applescript Automator action and a
cocoa pipeline stage so before we get to
creating stages though we need to talk a
little bit about what is necessary in
your application so even you can
actually write Automator actions and
first your applications technology needs
to be either or both have a scripting
dictionary which allows you to write
apple script based actions or api's
which would allow you to create actions
using cocoa so the framework for the
rest of what you're going to see today
is that if you need to make your
application scriptable you need to be
familiar with Apple events and if you're
after the cocoa app cocoa scripting and
but what I'm primarily going to talk
about today our apple script studio and
cocoa bindings and xcode to actually
build actions now all these technologies
have lots of documentation on both the
sea DVD and the apple website and there
are a number of sessions on all these
topics this week as well so is that I
now promised you just I'll show you how
to fill in that workflow can we come
back to demo one please
so let's clean things up here so what we
need to do is add a run script action to
our workflow will add that in right
there that's where we need it let's
remove the comment we helpful comment
with yet and to save you watching me
type I'm just going to drag in this
clipping of the code compile it to
format it and what we're doing here is
we need to tell exco to do something so
we're relying on xcode script ability
and all we need extra to do is open the
projects that we pass in and then use
xcode script ability to add a new build
setting to the first target in my
project and what I'm going to do is add
a build setting with key other OS a
flags and value dash X and what this
option does when it's past oh SI compile
is strip out the source in the bill
product so let's go ahead and run that
workflow so Xcode now is open each
project and adding that build setting
and then now building the project and
we're doing a clean so we remove the
version that have this script in there
and here's our build results and we can
search through here to find to make sure
that the option has now being passed osa
compile and there it is and just to be
paranoid let's go back to finder and
look in our build products and make sure
the script is no longer there and it's
gone so now this is this action is safe
to send to our customers if we don't
want them to see the source so this is
great I've solved my immediate problem
but it's completely specific to it can
go back to slides please but it's
completely specific to this product this
exact problem I'm trying to solve you
can imagine that you might want to set
different build settings and different
values at different times so maybe this
would be a useful action to create a
fully fledged action and you'll see that
soon but before we get to that we need
to talk about the SDK so what I hope
you'll get out of this portion of the
session is better understanding of the
various steps that go into building an
action from understanding the way the
Xcode project is laid out
the building a new user interface and I
be using cocoa bindings to connect the
elements of your user interface to your
code and the demos we're going to show
you today will be shown in both writing
code and Apple script and objective-c
and to do that you need to know about
the Automator api's and public classes
and finally the info.plist that's part
of the action is very important it gives
automator a lot more information about
how to present your action to the user
but wait there's more I'll also touch
briefly on how you test an automator
action and then how you install it and
finally some design guidelines analogous
to the application interface guidelines
that we've developed for making actions
that will work and feel to users the way
that the ones that we create will so the
project layout this is actions are built
using standard Xcode projects and again
we've got the two templates today and
depending on which one you choose you
will get either a main script or a
header and source file pair a main nib
to hold your actions user interface if
it needs one it doesn't have to have one
you saw the new text edit document
action doesn't have a user interface
because there's no options that are
necessary a description at RTS D which
is a textual description of what your
action does and that's what appears in
the lower left-hand lower left hand
corner of the automator user interface
and finally being put out feelers which
I mentioned a moment ago and instead of
telling you more about the rest of the
steps in building an action I'd like to
ask Tim Bumgarner from the automator
team to come up and give you a
demonstration of creating an action
using Apple script please welcome Stan
Thank You Todd what I'd like to do is
we're going to go ahead and we're going
to say this one close it up we'll reuse
that workflow and we're going to take
and replace the run script stage that he
created stage action we're going to
create that every place that action was
something that we create using Apple
script and as you mentioned we do have Q
templates for you so if you were to go
to the file menu of Xcode itself and the
after crashes lucky me
thanks for take evidence for g5 okay
it's a new project we go to a new
project and you'll see that there are
two choices and you and you have to look
for them they're a little further down
they are down in the standard apple
plugins you'll see that there's an
applescript pipeline stage this is the
project template you'll want to use if
you want to create it predominantly
using Apple script it's not it doesn't
preclude you to adding additional
languages but if you want to include at
least have your being run part of this
stage or action be part of that you'll
want to use this template if you want it
to be used objective-c or other sea
based languages you would choose the
cocoa pipeline stage but for our demo
purposes let's go ahead and open up a
project that I've got sort of started so
we don't have to watch me laboriously
and drag out user interface items so I'm
going to open up my project and as he
mentioned we have it looks very to those
of you that have used apple scripts to
do very similar we have a script folder
here that has our main script let me
open up a editor window and we've got of
course the other part that's interesting
to us is our nib so I have a glad and
look at the interface for this actions a
little about to write and you can see
that in his run script what he did is he
took a key and a value and he put it in
the build settings of the first target
of the each project as it came in to the
action so we're going to do is build
this action so it could be used much
more in a generic matter i could at any
time i decide i need to add a new
setting or change an existing study i
could use this action and you can see
I've got it laid out I've got the
setting this will be the name of the
setting and the value that we might put
in and i've added one additional twist i
can not only choose that i want it for
the first target i can actually have it
applied to all the targets that happen
to be in that project but the way that
we put this together is that we will use
this object you'll see down here in the
project window this is the parameters
object that gets passed to your action
from one step to the next so as you're
actually gets executed this is what's
going to be past it so what we're going
to do is we're going to bind if you've
got to see the cocoa bindings or
experience with it we use cocoa bindings
nearly all of our actions so I'm going
to go to the info panel but the bindings
and on this first one I'm going to bind
it to its value and I know that I want
to call this
name go ahead and hit enter by net I'll
go to the value and it will bind mr.
setting value and on the last one it's
not bound to its value it's actually
going to be bound to its index we want
to know that if it was going to pass an
integer and as a parameter 0 will be for
first one will be for all so I'll go
ahead and type in which targets that I
want so everything is pretty well set
that's all I need to do for the
interface keeping in mind that this is
the portion that's inside of each little
action that you see so we're just
responsible as an action writer for the
content Automator takes care of making
sure you end up in the right order and
passing all the information that you
need so let's go back over and we're now
going to edit our script and let's make
this window a little larger and you'll
see that I have the ever the template
starts out with a simple on run this is
what gets executed as the stage as the
workflow is going through its process
and what comes in is the input is the
output from the previous stage and then
the next thing that comes in is the
parameters that the user set up in your
UI for your action and so what I'm going
to do is we use Todd's little script
because it's predominantly very much the
same script we're going to make a couple
additions to it so the first thing I
need to do is get some values out of
that parameters object and let's see
we'll do a little one handed typing here
and put in a couple things so we've got
a setting name we're going to pull that
out of the parameters object let's check
some text so far and we've got the value
and we've got our target and week or is
it to an integer just to make sure we
get it in the format we want the only
thing that's left to do is the way that
the script was originally written was to
only apply a fixed value he was always
passing in other wesley flags he was
passing in a key and he was always doing
it for the first target so what I want
to do is grab this and I'm going to
replace it and I'm going to test that
which target if it's zero that means I
want to apply it just to the first
target so it looks very similar to what
we just had except for now I get to pass
it the real value and or the value
that's passed in our parameter and also
the name and if I continue on it says if
which target is one this means all so
I'm going to go through and I'm going to
do a little repeat loop for each target
in the specified project
I'm going to do the same thing i'm going
to apply it there so let's finish off
the rest of this i'll go ahead and save
that and what i'm going to do is we use
a custom executable is set up for you
automatically in your templates so when
it's time to run what you can do is edit
your argument setting I'll bring up the
inspector and you pass then the argument
in this currently it's called dash stage
it'll be bash action hopefully and you
just give it the in quotes the name of
your stage or built product that you're
building and what we'll do is when i run
this Automator looks for that argument
it's an optional launch argument and
it'll take your built version and use it
inside of Automator instead of having to
worry about putting it building it
copying into the right location so i
could find it it's much easier to do
this particularly if you're taking
objective-c or cocoa programming you can
debug these very simply using the same
process so we've got our application i
might go ahead close that go back to our
previously saved one and what i'm going
to do is go ahead and go up here we're
going to delete this ignore the little
artifact and i'm going to go find the
one that i just created i believe i
called it set build settings so i'm
going to drag this in here i'll put it
in its place where it was before i'm
going to put other osa flags and i'm
going to pass that def x dash x and in
this case instead of just the first i
want to apply it to all so i think
everything looks good i'll go ahead and
build and run and you'll see if you can
write here the back it's actually
opening each project in Xcode and
setting the value it's now building
those and if i do the same sort of thing
and search for dash x or dash x you'll
see that it is indeed being path 3 let's
make a pile so you can see how very
simple it is now i can put whatever
build setting i need to apply to that so
it's very simple to take that prototype
and wrap it up into a user interface and
put it in using Apple script thank you
so now you've seen how to create an
action using Apple script the next thing
is to talk about how to create an action
using cocoa and to do that we need to
discuss briefly the cocoa ap is so again
we receive the name pipeline but these
are in the pipeline engine framework and
there are two public classes of interest
to developers that want to create pipe
pipeline Automator actions using cocoa
PE stage is the abstract base class but
PE bundle stage which is a subclass of
PE stage is the stage that you will want
the subclass from to create your own
actions and it adopts the NF coding and
is copying protocol so what I'd like to
do now is a skerrick payton another one
of our Automator engineers to come up
and show you how to build an action
using cocoa thanks d well so we thought
Tim do the whole thing in apple script
and it was fast and was quick and it's
easy it's just as easy to do the same
kind of thing in objective-c however
instead of repeating what Todd and Tim
have both done I'm going to go ahead and
create a different action that does
something a little bit different what
I'd like to do is one of the things that
all of this generates is this big text
edit documents the end well ninety-five
percent of what's in that text edit
document is what was successful well you
don't really care about what was
successful in the build that's great
fine wonderful what you really are
worried about is what warnings that I
get what errors did I get during my
build so what I'd like to do is I'd like
to create a small action that parses
through all that text finds the warnings
and errors encapsulate that information
creates new text and passes that to the
text edit document that gets created and
to do that we're going to use a cocoa
Automator action instead of a apple
script one now as Tim showed you just go
into projects new Koko pipeline stage in
these seeds and create your action will
do the exact same thing and I'm going to
go ahead and start off with a run dem oh
ok I'm going to go ahead and start off
with a with a prebuilt stage so that you
can see it we can go ahead and close
this we don't need that open right now
and as you can see here I've got a
prebuilt one called create build rapport
you'll notice it has the executable
automator executable already set up for
us and all that kind of stuff if you
look in here in the classes you'll
notice that there's a create build
rapport th and a create build rapport am
in the dot H you'll notice that it is a
PE bundle stage as Todd just mentioned
in the last slide and in the code you'll
notice that it has a one method run with
input from stage error now this method
is all you really have to have to make
one of these things of course you can
extend and do as much as you want
outside of this but this method is
called at runtime when it's your turn to
go we pass you the input from the
previous stages our previous actions
output we passed you who that person was
in this case it's called PE stage and we
passed you an empty dictionary which you
can fill up with your error information
that can be passed back then presented
to the user if something happens during
the flow that you want to return before
we add the code into here we need to go
into the nib and do essentially the same
thing that Tim did and everything is
managed using bindings on this save you
the work of managing saving the
Preferences off we take care of
everything is everything is bound
correctly there's nothing for you to do
you draw your interface you hook it up
to the bindings in the parameters object
and you're done in this case we have
included a check box to include warnings
in the build rapport and what this will
allow you to do is if checked it will
show you the actual warnings in the
build rapport instead of just the number
of warnings so we will go ahead and move
that go to the bindings we will add a
value include warnings and we're done
we'll save off that nib and it's
literally just as easy as that you drop
a check box you add it to a binding
you're done when Todd a little later
talks about the info.plist you'll be
able to see how these defaults are set
for these different bindings and
everything for you in our info.plist but
for the most part at this point your
interface is complete we will go back to
our code and in for expediency sake
instead of showing you all this code I
will go ahead and just copy
and paste it here and what I've got is I
have got a run with input that's already
filled out the intention here to take
that data that is passed to us course it
into a string parse through that string
looking for specific tokens count up the
number of warnings and errors create a
new string that we want to show to the
user and then spit core step back into
whatever need to be passed to the next
object in the flow will get a string out
of we will get a string let me scroll up
here we'll get a string out of it what
came in previously which we call the
build rapport here the input we go
through we course we look for certain
things that happen to be in the exit out
but of course in your code you might
want to do something far more fancy
using reg X's and and stuff like that
but this is just an example we look for
warnings we look for errors we add them
all up and create a new string and then
we return and as very empty you'll
notice here we return an NF apple event
descriptor descriptor with string now
we're doing this because of something
else you're going to learn about later
you declare declare your data types in
this type we're saying we're a data blob
and a data blob is defined as our NF
apple event descriptor there's more
about this in the sdk and it's not
something that is germane to this exact
situation but let's go ahead and save
and build and it should finish and run
and you notice when Automator starts
here i should have a build reports page
so here you can see the build rapport
stage so let's go ahead and open up our
previously built document and we will
add our create build report at the end
of our workflow but before our new text
edit document you notice here that it's
already automatically checked for us
you'll see later that oh yeah you'll see
later that that the default parameters
we had set in our for our bundle have
this already set to be on by default
even though we didn't have to turn it on
in the nib we already read the defaults
out of the bindings and set that one
thing will also do is we'll go ahead and
disable the set build settings we've
already set to build settings all these
projects when I disabled it I
checked on the disabled enabled disabled
box up there in the upper right-hand
corner of each of the actions and that
action will be skipped over in the
workflow it will not execute and it's
grayed out and in stuff and you notice
it a little dash there instead of a
number letting you know that it's
disabled I should now be able to save
and run this thing and what it will do
it to the Queen and build all my
projects it will create a build rapport
and there we have our little build
rapport and it threw away all the stuff
we didn't care about left us with the
total warnings one and a copy of the
warning unused variable unused variable
which we don't write code with warnings
so we had to actually insert one for
your sake of course and that's my demo
back to you Todd well thank you very
much Eric and I just wanted to underline
22 points that Eric made but to make
sure you you you get this if you saw
there was no script smart group and
Xcode there there's no Apple script
there at all now we love applescript but
if you prefer to work in cocoa that's
great you can do that to create your
Automator actions and the other thing to
mention is we've been showing cocoa
bindings exclusively for managing the
actions user interface but in fact you
can use what you used in cocoa before
cocoa bindings existed or you can use
Apple scripts to do and also if you
already know that technology so we've
already made several references to the
info.plist of your action and what I'd
like to do now is give you a little road
map for which keys are there and what
they're used for so therefore kind of
basic keys these are all strings and
they're reflected in various ways in the
automator user interface PL application
is the first one and this is used to
specify which application that your
action uses to do its work and you can
use that to search to find actions PL
category is again a string and you can
use one of ours that are shown in the
user interface where you can create your
own which can be used by users to do
searches for your actions
PL icon is used for the icon that
appears next to the actions name in a
filtered actions list npl name is used
for both searches as well as for
displaying the action in the filtered
action once as you see on the screen
shot so let's get smart into one of the
keys is a little more complex and
interesting the exception provides
dictionaries are the actions way of
telling automator what kinds of valid
input it can handle as well as what kind
of output it provides so both of these
dictionaries contain a types array which
allow you to specify one or more type
identifier strings which I'll get to in
a moment again to tell automator what
kinds of data it handles the accepts
dictionary includes an additional key an
optional boolean which tells automator
whether or not your action requires
input to do its work action some actions
don't need any input to do what they're
going to do and you can tell Automator
that in the accept optional boolean that
will allow Automator to tell users
whether or not a particular action can
be used to start a workflow for example
so type n identifiers they're loosely
based on Apple's uniform type identifier
these are just a few examples the first
being the most general type that is the
default that you will get when you
create a new action project and the I
guess we don't actually have it up there
but public got data is the the type that
is returned by the create build rapport
action that Eric just built but this
just gives you kind of a flavor the the
complete list of current type
identifiers is in the release notes on
the seed DVD so a few more guidelines on
accepts and provides dictionaries you
really want to keep in mind that the
more other actions that your action
works with the more useful it's going to
be to users so you should really think
about how interoperable it will be based
on the types that you support you should
make the accepts and provides types of
specific as you can that gives automated
the maximum guidance so it can provide
guidance to users on which actions are
appropriate to go next in their workflow
they're building I've alluded to this if
the types is an array that you can
specify multiple types and you should
definitely do that if your action can
handle them
we have several actions in the seed that
can handle multiple types such as I
photo photos and albums it can by itself
extract the photos from an album that's
passed in if your actions doesn't need
any input to do what it's going to do
for example our log output action which
just allows you to see what the input
from the previous action is in the
workflow you should just return the
input you're given as the output and
leave the types general which is the
default so yet another kind of side
issue here is that you're out when you
create actions for your own applications
your own your applications have
different types then say I photo does so
you may want to create your own type
identifier strings and you can
definitely do that what you might want
to do in addition if you do that is to
create conversion actions and what
conversion actions are are to link
actions whose types don't directly match
for example in South demo yesterday you
saw that he had an import images into
iPhoto action which returns I photo
photo objects and that as the input for
the create new ivd slideshow action
which expects files now why did that
work because the iDVD action doesn't
know anything about I photo photos well
what happened is that there we have a
conversion action from iPhoto photos to
file and the neat thing here is that as
you saw there was no extra action
inserted there Automator automatically
detected the need for it but it
invisibly adds it to the workflow so the
user needs to know neither that it's
necessary or that it's there and you can
add these for the new types that you
create let's one one last detail there
that's on the slide which you can
obviously read but these are built
exactly like any other Automator action
the only difference is once you build it
you need to change the extension of the
bundle from stage to dot C stage so the
next key I'd like to talk about it and
Eric mentioned this already the PL
default parameters this key is used to
hold default values for the values that
you're managing using cocoa bindings and
this is why the checkbox that Eric added
to the user interface was checked when
we launched the action because we had a
PL default parameter in there
to set the value of the checkbox to true
and these are just based on the types
for what the user interface element
needs these are just a few examples so I
showed you the keyword interface in the
first demo this is an array of keywords
you can specify as many keywords as you
like and you can use the ones that we've
created which you can see in the
interface as well as create your own
again users can still search for
keywords that don't appear in the
keyword interface now p 0 required
resources again a little bit more
complicated but again very useful if
your action needs some resource to be
installed on a user system for it to
work properly this allows you to tell
Automator hey I need this thing or I
can't work so let the user know that I'm
not going to work and there are three
ways to do this the first is shown here
on the screen you specify the type
application and then you can specify the
applications resource by its bundle ID
its display name which is what's shown
in finder and its version and the
warning screenshot shows what the user
will see if they try to add such an
action without that resource being
present on the system now there are two
additional ways to specify this you can
also specify it by creatorcode and you
just change the type for an application
to creatorcode and then specify the
Creator code as the resource string and
finally if it's not an application that
you need on the system for this to work
its some other file or folder of some
sort you can do that as well by
specifying a required resource of type
file and specifying the full path as a
resource now this I also showed in my
original in my first demo today if you
add an action that can lose data from
what's passed into it you need to tell
Automator that with this PL warning key
and you'll the user will see a warning
as shown here and as you saw earlier
what you can do is propose a new action
to be added before your action that will
make the workflow safe and that's what I
did in my demo when I was going to scale
images another example of crop images
you obviously could lose data from
what's input that would be a level two
level one we're using for reversible
changes for example flipping an image
you can always flip it again to get
back the original and you can also
specify exactly the way that warning
will look the message the action is
proposed if necessary and the button
labels as well so those are the major
steps in creating an automator action
now I'd like to just talk briefly about
well okay I've created this thing in
Xcode now how do I make sure it works
properly well we've shown you this
already what you can do is add a custom
executable to your action project and
with the seed it will need to be a
pipeline custom executable and add a
launch argument bash stage and then pass
the project name dot dot stage and what
this does is it passes that argument to
pipeline when it runs and it will appear
as if your action is already loaded in
pipeline this makes the development
cycle much more efficient and very much
like what you would be used to from
building a normal application so once
you've got automated running and your
new action is there you need to test fit
in the context of a workflow and when
testing workflows what you can do is use
the log output action which I've also
already mentioned and you can add that
in between each action that you want to
see the input going into the next one to
verify that your actions working
properly if you also want to be able to
pause or cancel the workflow at any step
in there you can add another action
which is on your seed confirmation
dialog and if you add this pair of
actions between every action in your
workflow you can actually step through
each step of the way seeing the output
as it goes into the input of the next
stage so where do actions live well the
actions that we provide are in system
library pipeline currently and that
again will obviously change when you
build your own actions it depends on
whether you want them to be available on
a per user or a per machine basis and
you can then install them in the proper
library folder
so now that we've talked about from
beginning to end of building your action
I'd like to kind of back up and get you
to think about some of the guidelines
that you should think about as you're
laying out your interface and even
thinking about what should your actions
do so why do we need design guidelines
what we want to help you to achieve a
consistent look and feel with every
other action out there both that we
create and that your colleagues will
create we encourage you to use our
actions and examples you can see all of
their user interfaces and how they
operate obviously in workflows and we
will ship as many examples as we can
with the actual project source the
materials that you can download from
connect apple com for this session
includes three example projects of
actions that we've created and the draft
guidelines which cover a little bit more
than what I'm going to talk about today
are in your release notes on the sea DVD
so first a little bit of philosophy
about how we think about actions we
think that you really should try to keep
them as small and discreet as possible
keep separate axes actions separate the
better way to combine two different
tasks is to combine two different
actions in a workflow not to kind of
crammed them together into one large
complex single action that's going to be
both harder for users to understand what
it does and to configure and also it
will probably make it less likely to be
interoperable with other actions so
again the overriding goal here is to
keep it simple it's a little bit about
naming actions we encourage you to use
longer more descriptive names as you've
seen in the action filtered action list
there's quite a bit of real estate
therefore to use a longer name for
example add attachments the front mail
message that gives a very good
description when a user is looking
through the list is this really what I'm
looking for do you use laurel objects
action should handle multiple objects it
may be that you're only passed one but
you should not have an action that only
accepts one one object and in that case
the name should match the only time you
should use a singular object is if the
action accepts only a single object to
multiple
other objects an example here is we've
got a series of action to change file
names and in the ad date to file names
action there's a single date that gets
added to each file name so in that case
the date would be singular and finally
don't don't use s in parentheses to
indicate that your action handles more
one or more action objects every action
should handle multiple objects so you
don't need to let people know that it
handles both one or more again in the
interest of keeping it simple you should
minimize the use of boxes there's one
specific example I'll come on to in a
moment where a box is a good idea but
you should try to keep it to a minimum
your your user a face should should be
as small and clean as possible he's got
too many things that need separate boxes
you may want to think about splitting it
up into multiple actions and as you've
seen we've got kind of more width and
depth in the workflow area so you want
to minimize the use of vertical space
one good way to do that is avoid radio
buttons and use pop-up menus instead
even for as little as 20 two choices
because the the pop-up menu is going to
use less vertical space more on keeping
it simple you should avoid tab views
again this is a pretty good sign that
your actions getting too complicated if
you need a tab view again there's an
exception that we will have in one of
the actions that we've created crop
images when cropping images you might
want to crop by dimensions or by
percentages and as you can see in the
screenshots those two different types of
cropping require very different user
interfaces and instead of having them
both there in the action one way to
avoid that problem is to use a hidden
tab view and then when the user makes
the top level choice you can swap to the
proper interface and keep things simple
another thing that will give users a lot
of guidance is to provide feedback and
again one one example of that our
progress indicators we've got an action
called create events for people that
needs to populate a pop-up menu with the
ical calendars that the user already has
on their system so when the user adds
the acts of the workflow we need to ask
I chow for those calendars to talk to
it's pop-up menu so there's a little
progress indicator to let the user know
hey wait a second before you try to
start trying to
figure this action I need to do
something another way to provide
feedback is to give the user an example
of what actually the action is going to
do to their data and they're too two
good examples here this could be
textually or graphical example the
fourth images action does it does it
very well graphically by giving you an
example image and then what it will look
like after the action is through and for
the next sequential file names action
down the lower left lower left-hand
corner it gives you exactly what the
resulting file names will look like
based on the configuration the user has
chosen in that case you should you
should put these examples inside a box
this is the one exception labeled
example and use the same font in color
and font size and color that you've used
in the rest of your user interface so
it's not glaring it's there for the user
to find but not necessarily in their
face so a little more guidelines about
the guidance on the layout of your user
interface we do use 10 pixel margins
around the outside of your actions user
interface as Tim mentioned during this
demo you only have control over that
piece of the user interface Automator
itself then needs to add around it the
title bar and the other pieces that
you've seen in the workflow area and by
using a consistent margin around the
interface you control that allows us to
do a better job of making your action
look good when a user adds it to a
workflow use small controls and small
text within the interface again this
helps to keep things these little space
so that users can fit more actions in
the visible area network flow unless of
course you've got one of our great new
30 inch displays in which case that's
really not relevant anymore and we
encourage you again to follow the apple
human interface guidelines wherever
possible one thing to avoid and we've
confessed here this one is still in your
seat and hasn't been cleaned up yet but
don't repeat within the title in the
user interface that you create that just
again waste space the user can read the
title and understand that this is about
changing the case of file names so
finally one thing that many actions need
to do is ask the user for a location for
to either save a file or find a file or
folder
and we'd like to standardize this across
action so you just know what to expect
this gives you an idea of what that
should look like a pop-up menu with
standard locations as well as three
additional options so choose option
which allows the user to choose another
arbitrary folder on their system prompts
user which as South showed in his demo
yesterday will allow the when the
workflow is executed will then prompt
the user that's running it to enter the
selection at that time and finally a
temporary items option which means that
this is for files that are only needed
during the context of the workflow and
then will be removed by Automator at the
end of the workflow execution and what
we will do to help you standardize this
is we will provide a widget in a
pipeline I'd be palette well it'll be
called an automator IV palette when you
see it that you can just drag out into
your user interface and it will be
configured properly to meet the
guidelines this is not in the seed yet
but we will we will give this to you so
to sum up I want to make sure I hope
that you've learned and understand much
better what Automator is why it's
important to you and how you can develop
for Automator using your applications
technology we really want users to be
able to use Automator to automate all
sorts of interesting tassel necklace 10
and the more applications that have
actions the easier it will be for them
to do that so you have a few actions
items as it were make your application
scriptable if it is not so that users so
that you and your customers can create
actions using applescript to create a
set of AP is that you can use or your
customers can use to create actions
using cocoa and to create a great set of
actions that make your application look
good and allow customers to incorporate
it into their automated workflows and
therefore you you've got a customer for
life
so we have some hours when the Automator
team will be available to speak with you
to answer any questions you may have
this afternoon in the macalistair labs
and tomorrow morning there's a there's
not a lot of documentation yet available
there are release notes in your on your
CD DVD and updated release notes in the
materials for this session as well as a
tutorial and the sample code I mentioned
earlier as well as the project from the
demos you saw today and again there's
lots of documentation about the other
technologies that we've discussed today
as well as sessions this week these are
some contact information in DTF and the
technology management