omar Posted October 21, 2015 Share Posted October 21, 2015 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? Thanks. Omar Link to comment
deanishe Posted October 22, 2015 Share Posted October 22, 2015 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
matthewstroh Posted August 29, 2018 Share Posted August 29, 2018 (edited) 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). In Alfred, go into the Workflows area, click the [+] in the lower left-hand corner and select "Blank Workflow" Give your new Workflow a title (I chose "My Email Greetings") and click [Save] Right-click on the main working area (where the Alfred components go) and select: Input » Keyword 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. Make sure to choose "No Argument" and click [Save] Right-click on the main working area and select: Actions » Run Script In the pop-up that appears, change the Language to /usr/bin/python as deanishe noted above 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] Right-click on the main working area and select: Output » Copy to Clipboard 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] Connect the Keyword to the left side of the Run Script component Connect the right side of the Run Script component to the left side of the Copy to Clipboard component Open up a text file or email and test it out with the keyword "greetings" (or whatever you chose) If you're satisfied, then go in and change the sentences in the Run Script If you're really satisfied, buy danishe a beer using the link in his signature! Edited August 29, 2018 by matthewstroh deanishe 1 Link to comment
deanishe Posted August 29, 2018 Share Posted August 29, 2018 24 minutes ago, matthewstroh said: If you're really satisfied, buy danishe a beer using the link in his signature! I am currently enjoying one of the beers you bought me. Thanks very much! matthewstroh 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now