Jump to content

Simple Ideas: double trouble—hidden delights of the Keyword Input

Recommended Posts

Alfred's Keyword Input is more versatile than you might at first suppose. Of course you can use a keyword without any argument: I use one like that to open a deeply nested menu item in Day One.

However there's much more you can do with the Keyword Input.

The skeletal workflow

1. In order to set your teeth on edge we'll use the keyword Fraze. If we double click on the Keyword Input this is what we see:

It shows the keyword we're using to trigger the workflow and indicates that should be followed by <space>, an argument then . The argument is the first part of the phrase.

Note the title forms a helpful prompt we'll see when we trigger the workflow. Prompts are really important and helpful prompts really facilitate the use of workflows—so make use of them!

If we trigger the workflow we can type the first part of our phrase:

Note we've sensibly added a space at the end of the phrase because we know we're going to add a second part. However, never trust users! So, after…

2. Telling Alfred not close his window (explained in this post)…

3. We take control of spaces, decide to deal with them ourselves in order to avoid nasty surprises, so use an Automation Task simply configured (by double clicking on it) to remove trailing white space.

4. We save the first part of the phrase to a variable:

We use a variable because we want to take control of assembly of the phrase.

5. It's time to prompt for the second part of the phrase and to reveal a very neat trick of Keyword Inputs:

This time we don't use any keyword. This Keyword Input is simply a device to collect more user input in the course of the workflow. We still require an argument (the second part of the phrase) so we leave that as is. Note again we have a helpful prompt. This one reminds the user of the first part of the phrase by using the variable we created in 4 above but with an added ellipsis and quotation marks.

6. After again telling Alfred not to close his window…

7. We use another Automation Task to trim white space—but this time from the start of the second part of the phrase just in case a user has tried to be clever.

8. At last we can assemble the whole phrase:

Our variable introduces and quotes the phrase and takes control of the spacing between the two parts of the phrase.

9. All we then need to do is to put our variable into Alfred's Large Type Output:

so that when the workflow runs with our inputs it shows Your phrase is: 'Spam is significantly overrated'. You don't really need another screenshot just to show that it works, do you?

In conclusion
You can use a Keyword Input without a keyword to scoop up more user input in the course of a workflow—and, of course, you can do that as many times as you need. However, do remember to provide users with helpful prompts when they have to respond to any Keyword Input that requires user input.


The Simple Ideas posts

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...