Jump to content

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


Recommended Posts

Background
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
SkeletalWorkflow.thumb.png.045555405a2f674300d7c51a3c0ad495.png

Explanation
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:
KeywordInput.png.10062fada8851e3729fe831e8569a657.png

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:
FirstPrompt.thumb.png.8a9cff9bc59dfdfbc1570e3ae18e40f3.png

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:
SaveFirstPart.thumb.png.54ca21bd96ddf90a5b5c46028081cfe9.png

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:
SecondInput.png.af458fbc99c6d03073b3ba124bb637ee.png

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.
SecondPart.thumb.png.2f0e97e87b6d7868ce8a9a63beccc239.png

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:
Assembly.thumb.png.d0588dca17fbbdbe599ebc801ba82527.png

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:
LargeTypeVar.thumb.png.1be9419ad67a751f7248cb7cfd498b13.png

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.

Stephen

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...