The other day I was putting together a screencast using Screenflow to show off a new site feature. I realized that I actually needed to *pay* for the software. I have made 70+ screencasts with Screenflow but that was at my old job and I no longer had a license.

Time to buy a licence. But first, to see if there were any discounts out there.

I pulled a promo code off one of those coupon sites (didn’t work, but that’s another rant) for 30% off. Naturally, I wanted to know what that was.

I pulled up Alfred to use its calculator feature. You just type in an equation and it knows you’re doing math.

**Fun Fact**: You can use natural language with the Wolfram search on Alfred. A query like “wolfram 30% discount on 127” will get you the answer you want. This of course will open up a new tab on your browswer to show you the result, and that to me is not very efficient.

As I typed out this formula with all it’s operators and parentheticals and whatnot, I realized that I do this a lot. I’m a cheapskate and frequently compare discounts and price points.

I do this a lot…

“Hey!” I thought. “I should stop the straightfoward thing I’m doing and skew off on a macro making tangent!”

And so I did. Will you too?

**Define The Workflow: Calculating a Discount**

I want a solution that requires the least amount of steps and doesn’t open new apps or windows/tabs, so I used Keyboard Maestro.

The marco will do the following

- Input the
**Initial Price**and the**Discount** - Perform necessary calculations
- Put the result onto your clipboard
- Notify you that it’s done

**The Macro**

- Let’s go action by action on how this works

**The Input**

**Action**: Prompt User for Input (Variables)

A *variable* stores a value like text or, in this case, numbers. Whatever you enter in the variables field will be the variable creatied. I’ve used **Principal** for the initial price and **Discount**.

The **title** and **prompt** are for flavor.

**Get Rid of Percent Signs**

**Action**: Search and Replace Variable (Variables)

Calculations can only be done with numbers, so any percent sign (%) that sign works its way into the Discount variable needs to be removed.

This action searches for % and replaces it with nothing, effectively deleting it.

This is probably overkill since It’s just you using this macro and you know you don’t need it, but you might as well cover your bases.

**Calculate the Total**

**Action**: Set Variable to Calculation (Variables)

This action will create a new variable based off of a calculation we write with the two variables we already created, Principal and Discount.

Flashing back to middle school math, we can figure out the equation. You just need to find out what the **Discount** percentage of the **Prinicpal** is and then *subtract* that from the **Principal**.

Note that we need to multiply the discount by 0.01 since we input the percentage as a whole number.

**Deposit the Total into Your Clipboard**

**Action**: Set Clipboard to Text (Clipboard)

You may or may not want to paste this somewhere, but I feel that the clipboard is the best place to put stuff for later. If you’re using a Clipboard Manager then you can always use it later.

**Optional: Notification**

**Action**: Notification (Notifications)

I like notifications. They make me feel like the computer is my buddy while providing visual feedback that the macro ran like you wanted it to. This one gives the new total and reminds you what you did.

In Keyboard Maestro, you can use variables in text with the syntax %Variable%Variable Name%. It’s a bit hard to read in the action, but the result is straight forward:

**Triggering the Macro**

It’s up to you what you how you want to call up this macro. Personally, I don’t like hotkeys or string triggers for this type of thing because I don’t use it often.

I prefer to pull up the Trigger Macro by Name Global Macro.

**Conclusion**

And so you build another tool for your toolkit.

A common question can be answered lightning quick. No opening webpages, no Please Excuse My Dear Aunt Sally, no writing equations, not Excel, just call up the macro, enter a few numbers, get your answer.

Are there any other calculations you do often? Share with us and let’s build the library!