Yet again I’ve found a great use for Keyboard Maestro. I’m a web developer and often have to create “filler” or “dummy” text during development. In the past I’ve used Alfred workflows, copy-and-paste, browser extensions, and more. I’ve recently come up with a much cleaner (and more powerful) solution to achieving field-by-field or one-off dummy text.
What do I mean by field-by-field and one-off? Well, I use tools sometimes to automate filling an entire form repeatedly (Fake, Selenium, iMacros, etc.). I’ve even written a Selenium extension to inject random text into the fields Selenium is automatically filling. Unfortunately, this all takes time. Sometimes I just need to fill some fields in a form a few times and move on. It’s not worth automating at that point. Enter Keyboard Maestro.
My goal was to just have a tool palette that I can pull up when I need various types of dummy text. Here’s the finished result I’m using these days:
All of these macros are nearly identical. They do the following:
- Check if the user is holding the CMD key when they click the macro
- If they are, replace the field value with the generated text.
- Execute a fake.xyz() call in Python to generate the dummy text
- Store the result in a variable
- Insert the text from that variable
Here’s what this looks like in the User Email macro:
The README macro simply explains that these macros all require Python and the “Faker” package from https://fake-factory.readthedocs.org/en/v0.4/
The real beauty of the solution is that Faker is robust. You can use it to generate everything from social security numbers to domain names, first names to country codes. It’s all nicely-documented at https://fake-factory.readthedocs.org/en/v0.4/providers.html
I’ve provided an export of the macros as I use them currently. It should provide a good starting point for you. Download Macros
After you’ve imported them, just open the palette and leave it open while you use it. When you want to fill a field with dummy text, simply put your cursor into the field and click the macro you want. If you want to clear what’s already there, hold the CMD key when you click the macro.
It’s very easy to add more more macros, so if you find yourself needing something (e.g., fake credit card numbers) just copy one of the existing macros and change the macro name and the function call according to the documentation.