Jump to content

Can I have random autotext?

Recommended Posts

I want to have a set of 10 random ready made phrases.


I want to be able to insert these into an email reply in Gmail - at any time, I want a random choice.


Can I use Alfred to help me do this?







Share this post

Link to post

This Python script will print one of the sentences at random when run. Put it in a Run Script Action with Language = /usr/bin/python.

12 Drummers Drumming
11 Pipers Piping
10 Lords a-Leaping
9 Ladies Dancing
8 Maids a-Milking
7 Swans a-Swimming
6 Geese a-Laying
5 Gold Rings
4 Calling Birds
3 French Hens
2 Turtle Doves
1 Partridge in a Pear Tree

import random

sentences = [s.strip() for s in SENTENCES.split('\n') if s.strip()]
print random.SystemRandom().choice(sentences)

Connect the Run Script Action to a Copy to Clipboard Output (possibly selecting "Automatically paste to front most app").

Share this post

Link to post

Brilliant, deanishe! This worked perfectly.


If you're a beginner like I am, you might want to see the step-by-step of how I implemented it (for those who are curious).

  1. In Alfred, go into the Workflows area, click the [+] in the lower left-hand corner and select "Blank Workflow"
  2. Give your new Workflow a title (I chose "My Email Greetings") and click [Save]
  3. Right-click on the main working area (where the Alfred components go) and select: Input » Keyword
  4. Choose a proper keyword and write a title for your workflow – I chose "greetings" for the keyword and "Email Greetings and Phrases" for the title.
  5. Make sure to choose "No Argument" and click [Save]
  6. Right-click on the main working area and select: Actions » Run Script
  7. In the pop-up that appears, change the Language to /usr/bin/python as deanishe noted above
  8. Paste in deanishe's script above into the script area, making sure to remove the default 'query' content that was in the text area. Click [Save]
  9. Right-click on the main working area and select: Output » Copy to Clipboard
  10. On the pop-up window that appears, optionally check the box next to "Automatically paste into front-most app." I chose to do this so when I run my email greetings it will automatically put the text into my new email when I run the app. Click [Save]
  11. Connect the Keyword to the left side of the Run Script component
  12. Connect the right side of the Run Script component to the  left side of the Copy to Clipboard component
  13. Open up a text file or email and test it out with the keyword "greetings" (or whatever you chose)
  14. If you're satisfied, then go in and change the sentences in the Run Script
  15. If you're really satisfied, buy danishe a beer using the link in his signature!
Edited by matthewstroh

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...