How To Create a Ram Drive Using Keyboard Maestro

While it may not be common on most computers, I am a fan of using a RAM drive. For my work Mac, this is where all my music plays from. I also play desktop videos such as beach scenes to create a festive atmosphere. I use the RAM drive to save wear on the spinning disk. Although I have a 3TB data drive for the purpose, there is no reason to play 8 hours of music, all day, every day, from a disk when memory is more efficient.

In order to create a RAM drive, you need a lot of RAM. Setting one up on an 8GB machine will lead to tears. Lots of RAM is one of the reasons I love these older model Mac Pros. I can allocate 6-8GB of RAM without issue.

Although it’s a rarity, when the Mac needs to reboot, such as a security update, the RAM drive disappears. After the reboot, the RAM drive has to be recreated and the files recopied. Not a big deal, but why do it manually? Another task easily handled through automation with Keyboard Maestro.

Through Keyboard Maestro, I can prompt for the size of the RAM disk, create it, then use a shell script to copy over my list of files. I use a script file for ease of editing in CodeRunner. The script can be written in the Keyboard Maestro code block.

Keyboard maestro ram drive

What’s good about this script is it shows a Prompt for User Input block, then uses that response in the Shell statement.

The value for RAM drive size is stored in the variable: `instance__Size`
This is used in the Shell Script by prefixing `$KMVAR`, as in `$KMVAR_instance__Size`

This is an effective way to build a UI in Keyboard Maestro, and combine it with the power of the Shell.

The RAM drive is created using the `diskutil` command within the `Execute Shell Script` Action.
The Volume size is calculated using – `instance__Size * 1024 * 2048`.

The complete command is shown in the `Execute Shell Script` block:

`diskutil erasevolume HFS+ “RAMDisk” `hdiutil attach -nomount ram://$KMVAR_instance__Size`

The next command in the block calls the shell script to copy over a dozen files for several hours worth of music.

A playlist file based on the contents of the RAM drive is also copied over. Double click this and the files load into VLC.

Now everything is back to the pre-reboot condition. It’s all handled behind the scenes by triggering the process with a keyword. I don’t have to open iTerm, enter the command, then run the shell script manually.

Other articles of interest:

Prompt for User Input in Keyboard Maestro

One of the great things about Keyboard Maestro is the ability to design a UI for your macro. Using the `Prompt for User Input` block, the macro can be dynamic in how it works, or perform different functions based on user choice.

The prompt can contain an entry field, checkbox, dropdown, or buttons selections. The result is stored in a variable.

I have several macros with prompts, such as the size of a RAM drive, the number of times to click the mouse, a folder name, and what to rename a file. Those results are then used later in the macro or passed to the shell to move files, or create volumes.

A broad list of examples can be found at the Keyboard Maestro Wiki:

Keyboard Maestro- Prompt for User Input

The following examples are the ones I use most:

Text field: Variable and default value
Checkbox: Variable and 0|1 indicating checked or not (value must be 0 or 1, separated by the pipe)
Dropdown: Variable and Item1|Item2|Item3|Item4. Values are separated by the pipe symbol.
Buttons: Use the `%PromptButton%` token to get the name of the selected button. This will store the text of the button name. If you have a button called `Move`, the word Move is stored in `%PromptButton%`. You can assign a variable to the result of `%PromptButton%` to use at different stages in the macro.

Here is a simple example of prompting for input. It’s a trigger I use to test how a button handles repeated clicks.

The default number of clicks is set to 10. This can be changed at runtime.

The value is stored in `instance__clicks`
`instance__clicks` is then used in the Repeat Action block.

The click action is repeated based on the variable. The click action takes place under the current location of the mouse pointer. The move is set to 0,0 from current location.

To make note, `instance` means the variable is local to the currently running macro.

Other articles of interest:

Building a Simple Workflow With Keyboard Maestro

Building a Keyboard Maestro workflow is a great way to save time and make a consistent work environment. I trigger several workflows for writing, SQL, and automation development. This creates consistency by having all my tools laid out in front of me before I begin.

Let’s use my Journal workflow as an example. Before I begin writing, several things need to happen. I need to open and mount the DMG file that contains my .scriv file. I need to start Scrivener and load that file. I start Wordweb so I have a dictionary and thesaurus at the ready. I also start TextSoap for text cleaning.

They are simple steps, but when you pick each apart, there are multiple actions taking place. Here is the breakdown:

– Open Finder, navigate to the Dropbox folder, open the Scrivener folder, then load the DMG.
– Once the DMG is open, select the .scriv file inside and load it.
– Open Launchpad, find Wordweb and start it.
– Check to make sure TextSoap is running. If not, start it.

They’re simple steps, but each takes time to execute. With Keyboard Maestro all of this can be accomplished as a single task with no time spent opening files or folders. This is a great example because all the steps are predictable and repeatable. When that happens, we get the following:

Efficiency=Time Saved


As you can see, this is a straightforward macro that is easy to read. It mimics the same process I just described.

The first step is open the DMG file using the Open File module.

We need to wait for the DMG to mount, so we can access the files inside. The same as waiting for a hard drive to become available.

Once mounted, we need to open the .scriv file with the correct application, in this case, Scrivener.

At the same time, we can launch Wordweb, and TextSoap, so all apps are ready to be used. With one keyword all of these actions are invoked together. There is no need to manually look for a file, mount a volume, or switch applications. Everything is handled without breaking “flow.”

The same process is followed when I’m done. All the applications are closed and the volume is dismounted. Once the volume is dismounted, it can be synced through Dropbox.


Again, all of this is done as a single process. I don’t have to switch to each application, close it, switch to the next, close it, then check Finder to dismount the volume.

This may not seem like much, but I execute this process 300 times a year. I either work on an article or write in my journal nearly every day.

Let’s say by using Keyboard Maestro for this process, I save a minute of time each day. Not much on it’s own, but over the course of a year, it amounts to 5 hours.

Five hours of time saved by a single action is almost an entire workday. This marginal gain creates a huge amount of banked time.

It’s also not a minute. In reality it will be several, since manually going through this process is likely to break my train of thought, cause me to get distracted by an email, make me forget a thought, give me the opportunity to focus my attention somewhere else. That all leads to lost time.

This process probably saves 5 minutes each day. That would equate to 1,500 minutes for an entire year. 1,500 minutes is 25 hours, or 3 workdays saved. Not bad.

This is for a single macro, not a complicated one either. When set up for a dozen of events, the time savings is huge. This becomes banked time. Instead of spending time locating files, finding apps, or switching your mental context from one task to another, a single keyword can trigger a workflow that handles the task for you.

This can be extended to multiple workflows:
– Closing all your apps before doing a screen share on Zoom
– Apps and files you need when paying bills
– Apps and files for putting a recipe together
– Apps and files for setting up your task list for the week

With these simple workflows you can start more efficiently, be done sooner and move on to something else.

Other articles of interest:

Creating an Automated Job to Empty the Trash in Keyboard Maestro

Each Friday, I like to tidy up my machine before turning it off for the weekend. This includes several maintenances tasks including emptying the Trash. Like a real trashcan, why leave it sit?

With Keyboard Maestro, this becomes an automated task. With one code block, the trash can be emptied on a schedule. There is no need for me to remember. No need to switch apps. No need to accept a confirmation prompt.

As you can see from the screenshot, the Trigger is set to At Time. Since this is for my home machine, I have this set for 7:45PM each Friday. The one at work is set for 3:00PM. As long as the machine is turned on and I’m logged in, the macro will run. And come on, who isn’t logged into their at 7:45 on a Friday night?

The next block of the macro is the small piece of AppleScript it takes to empty the Trash. It’s job is to turn off the confirmation prompt, empty the trash, then turn the prompt back on.

While this is a simple macro, it takes the task off my plate. I don’t have to spend time thinking about it. I won’t get distracted remembering to switch over to Finder, pressing the correct key combination, or going through the menus, then selecting OK. It happens silently in the background, every Friday like clockwork. This is why we love computers.

For those who want the code:

tell application "Finder"
    set warns before emptying of trash to false
    empty trash
    set warns before emptying of trash to true
end tell

Other articles of interest:

Getting Started With Keyboard Maestro

Before getting on board with a tool like Keyboard Maestro, it's common to say, "I don't have anything to automate." Actually, working on automation is the old chicken and egg scenario. You don't have an automation tool because you aren't working on automation. However, you aren't working on automation because you don't have an automation tool.

You need to look at it from a different angle. I'm sure you've had this experience, you only notice how many blue cars are on the road right after you buy one. The same is true for automation. Once you have the right tool, you see all the ways it can be used. You notice the repetitive tasks. You see this is the third time you've done this job. Each week you clean out the Download folder the same way. There are multiple tasks to be automated.

Automation macros don't have to be grand programs. They can be simple, one hit wonders. In fact, those are best.

They don't need to contain elaborate decision making trees to handle a dozen scenarios. Rather, write a dozen small scripts to accomplish a single task. Use them weekly, or daily. When they are effective, you are saving time.

Some great script ideas are:

  • Building a workflow to launch applications
  • Build a consistent folder structure
  • Move files based on filename or extension
  • Delete files of a certain size or with a certain name
  • Rename groups of files
  • Trigger actions based on mouse button clicks

When working with Keyboard Maestro, the more macros you write, the easier it is to write macros. Even for a simple task, writing a macro takes less time than doing the task by hand. This is especially true for copy/paste jobs. I needed to copy dozens of pieces of text, then append them together. I quickly wrote a Keyboard Maestro macro to do the work for me. It saved time, plus kept the total tedium of the process at bay.

I'm now at the point of looking for ways to use Keyboard Maestro. I repeatedly ask, "How long will this take? Should this be a macro? Will I need to do this again at some point?" If that last question is a yes, I'm absolutely writing a macro.

Macros don't have to be perfect. I often spend a little time each weekend refining my "brute force" macros from the work week with better logic and capabilities. This refactoring takes less time each week.

The more simple macros I write, the better and more complex the macros can be later because I have a library of examples available. I can take a macro to add tags to files, then combine it with a macro to loop through a folder of files.

Especially now, there is always room for improvement in your daily workflow. Automation and Keyboard Maestro are a step in that direction.

Small macros save large amounts of time.
Small macros make work more efficient.
Small macros make light work of big tasks.

Other articles of interest:

Recent Comments

  • How To Disable the Quicken Registration Prompt (36)
    • I'm in LA: Left CTRL + Left SHIFT & clicking “One-Step Update” button (top of screen, just to right of Home button (house icon)) works on Quicken Deluxe 99. Thanks!
    • Suzanna J: *Ode to Microsoft Money* The most lovely, user friendly accounting software ever, I miss you so much MM, I dream of you, and wish someone would reinvent you. Q, Quirky, Glitchy, Bully, no love lost. the Control Shift Update to...
    • Pam: holding the *LEFT* CTL + Shift then clicking Online, One Step Update only works on newer quicken n not Quicken 98. Does any know how to delete this in the register or any other method.
    • Ray: Wow… post from 2010, I’ve got Quicken 2020 Version R24.14 — and this still works. Thanks for this info!! Of course Intuit doesn’t make this info readily available… they will nag you til you re-subscribe...
    • Mike: Hi, for anyone still trying to run older versions of Quicken, mine is 2004, I hope this helps. I managed to get it running on my old laptop by adding the three missing dll files, when I needed to upgrade I thought I would be able...
    • Juani: Hi, I have a registered Quicken 2016 and now my files are being held hostage by Intuit, cannot log in with my ID unless I upgrade therefore buy a subscription, I need to access my files, please HELP. Thanks
    • David: A BIG Thank you! I regularly reinstall Windows OS’s using different hardware configs. In short, Quicken 2011 (it’s March of 2020 as I write this) has been a program I’ve been very happy with and continue to use....
    • Karen L: Today I rang Reckon Australia again, got a different guy and he talked me through the process of getting me a new product key to enter since I already had the licence and it had been extended. Reckon have only extended it by 1...
    • Karen L: I have Australian Quicken 2008 on Windows 8.1. It keeps asking me to renew my licence which Reckon did for me however the activation won’t work. I tried this to disable the registration prompt however it did not stop the...
  • Enter dates into a date picker for Chrome and Firefox (1)
    • Prasanna: Hello, How to enter a previous month FIRST day and LAST day from the system date. Thanks Prasanna
  • Building Relationships with Developers (1)
    • Carlos Herrera: Ah yes. I have a team of software developers and it is genuinely so hard to keep them in the loop during projects. Though the more we work the better the communication becomes and we go from a trail and error process to a...
  • Integrating DevonAgent Pro with Alfred (1)
    • J. Garr: Beautiful, sweet, and simple. I love it; thanks for posting this solution.
  • Round and Round with the For..Next in Katalon Studio (1)
    • Sweet Ophaline Labador: Hello can you help me how to loop this scenario. Checking the elements is just the same. I want to check that the following function is available in Track Shipment – clicking on this can...
  • Parsing Strings in Katalon – Split, Substring and Readlines (6)
    • Don Pedro: String tempText=”Date Month January. Revenue $1,355,721.00″ println(tempText.split(“ \$”)[1]) You need to escape the $ with \$ The [1] on the split captures characters on the right of the split [0]...
    • Prasad: Hi, I need to get the substring from the below string ‘Date Month January. Revenue $1,355,721.00’ I want to extract text after $ value. Please help Thank you