Jump to content

Can I have random autotext?


omar

Recommended Posts

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.

SENTENCES = """\
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").

Link to comment
  • 2 years later...

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