I've hit a wall trying to do something in TextExpander, and wonder if KM could have an answer. I want to send an email that contains the person's name in a couple of places, which is fine using TE's fill-in snippets. But I also want to introduce a calculation where I want them to increase their contribution by 25%. So the email would have a pop-up where I'd enter an amount such as $4.00 and then a calculation would convert the increase of 25% so they'd see $5.00 as the new amount. In plain silly English (as an example!)
Dear Dr. Who, I'm so happy to have you as a supporter! You know, Dr. Who, last year you contributed $4 toward my jelly bean fund, and if you gave 25% more for my 25th birthday, your gift would only be $5 or only $1 more. Thank you Dr. Who for making my 25th year so memorable."
I looked at the calculation variable and at the wiki about it, and my number-challenged brain isn't putting the pieces together right. So I'm hoping that someone will find my invoking Dr. Who to make them smile will help me figure out a macro. Alas, I don't do script, though I have aspirations....
Could I do all of this using KM, or am I better off incorporating elements of TE into KM?
Thanks @ccstone! What a great teach-the-gal-to-fish experience, truly appreciated.
So I copied your macro line by line, and when I trigger it, the box comes up to input variables just fine. But after entering them, the KM display window opened where my cursor was, but without the entered information--just the script. Also when I clicked on the ok button for that box, it went away without leaving any text at all.
I'm using Apple's Mail app, and I assume I'm supposed to trigger the macro where I want the text to appear, right?
Thanks @ccstone, and sorry for the slow response.
Hilarious! I learned by typing though. Any advice about where to start at the very beginning?)
Ok, I downloaded it and ran it, and yay- it works perfectly, thank you! So now for the "still clueless part": should I be running it from within the Mail app where I'd be typing the message? Or should I fill in the name and amount as prompted, then add actions to copy the text that's in the KM Display Text box, click ok, open a new message in mail, then paste?
I realize that for people immersed in KM my question must sound like asking if I need to pick up my foot to walk. But I'm really good at a few things, and this is stretching me to new ones. Thanks again!
Fair questions (and useful) @ccstone!
I'm sending a version of the same email to multiple people. Here's how I imagine doing it:
Open an email in the Mail app
Type the address
(Here's where the automation would start): paste in subject line with something personal like Pommette to [name]: help celebrate our 25th birthday
Jump to message area
Text in message area: Dear [name] followed by an opening sentence or two, followed by the part you've helped me with: [last year's amount] with a 25% increase meaning a contribution this year of [new amount]. Thank you, [name]. Signature.
After hitting a trigger key, I'd enter the name and the original amount, KM magic would happen, and it would be ready to send. Maybe I'd add a personal tweak or two, then I'd hit send.
Open new email, repeat.
I hope this helps you help me!
Thanks again @ccstone!
Thanks @ccstone! I tried this a few times with a number of variations, but the macro doesn't run. I think it's because of my basic scripting illiteracy--as closely as I try to follow your excellent instructions, I suspect I'm in that place where I'm doing the equivalent of looking for the "ANY" key. So don't laugh too hard as I explain what I did:
Created a file named Pommette – Mail Merge List & saved it to the Documents folder where I believe it's saved as ~/Documents/Pommette – Mail Merge List.txt (at first it was saving as .rtf so I changed to plain text in preferences; it doesn't display an extension, but I'm assuming it's .txt)
I replaced the path in the Orange Read File action to: ~/Documents/Pommette – Mail Merge List
Meanwhile, in the TextEdit document called Pommette - Mail Merge List, I typed this as the first line (thinking this was what you meant by "with this format"): NAME(TABS)EMAIL_ADDRESS(TABS)LAST_DONATION_AMOUNT
Followed immediately (no line breaks) with the names & addresses (these are made up, but I entered real ones):
George Jetson firstname.lastname@example.org $4.00
Homer Simpson email@example.com $8.00
Peter Pan firstname.lastname@example.org $100.00
If you're throwing up your hands, please tell me the best place to get basic scripting literacy to make the best use of KM. I want to learn, but I need extreme basics, like how writing the letters A, B, C. We all start somewhere!
Personally I think no one who uses a Mac should turn OFF file extensions in the Finder preferences.
When they are on you can tell at a glance what file type you're working with, and you don't have to guess what your path is.
See the difference in the two path strings? If you did in fact use the second string, then you have an incomplete path.
Never type a path string if you don't have to.
The Finder will let you copy paths of an item by typing ⌥⌘C.
Select a file in the Finder.
Hold down the Option key.
You'll see Copy change to Copy as path.
You can also drag and drop items into Keyboard Maestro's path fields, and there's a file-selector button as well.
This line does not belong – it was just to illustrate the table format:
What belongs in in the data file is a tab-separated table like I thought I provided... I meant to include an example file along with the macro, and it looks like I failed to do so. (Now remedied in my post #10 above.)
Here's what it should look like:
Robert Heinlein email@example.com 5.00
Roger Zelazny firstname.lastname@example.org 10.00
Each row is a data record.
Each tab-separated value is a data field.
The fields may be separated by 1 (or more) tab characters to make a nice neatly ordered table.
One reason I'd have preferred that you used BBEdit for this task is that you can't accidentally save as RTF or RTFD.
It also has many tools for dealing with text that TextEdit does not have.