Generating random passwords with Keyboard Maestro
Even though there are a dozen tools and a dozen ways to generate a password, it’s possible to do that very thing using Keyboard Maestro. Why use Keyboard Maestro? Don’t be silly. The answer is obviously, well, why not?
This is a simple macro that uses a dialog to get the length of the password, uses a List (Array) to set up the password, the RAND function to pick a letter, and indexing the List to find characters. It may not be practical, but it’s educational.
I use this for generating test passwords. I test account generation on a regular basis and this makes sure we can handle special character and passwords of a certain length. It automates the process so I don’t have to switch apps, copy, then paste.
As you can see from the example, the first step is to prompt for the length of the password. This is stored and used in the Repeat function later on. By default, the length is 15 characters.
Next, we create a List to store all the characters we want to use in the password. This includes upper and lowercase characters, numbers, and multiple symbols. Some systems don’t handle
* and ! so adjust accordingly.
After we define the List, we need the length. In Keyboard Maestro using  gets the item count –
%Variable%instance_myList%. That’s very handy.
To generate the password we use Repeat and Rand.
The Repeat block is called the number of times specified from the user prompt –
To generate the password, the Rand function is used. A number between 1 and the length of the List is used.
Once this character is selected, it’s appended to the password string –
After this has been done the correct number of times, the final password is copied to the clipboard.
I’ve tried this quite a few times, and the password is pretty good. Using 15 characters I get results like:
When using KeePassXC, I get results like:
Again, this macro is more an example of Keyboard Maestro features and how it can be used for different tasks. It uses neat features like List, Repeat and Rand. And it was fun to write to see if I could.
Whether you use it for “real” passwords is up to you. Some would argue the seed values and true randomness. That’s not my discussion.
If you want to play along, here are all the characters separated by commas so you don’t have to type them out.