• Tech Tips

    Keyboard Maestro – Looping Through Each Line of the Clipboard

    This graphic illustrates how you can loop through each line of the clipboard and use the line’s value for some purpose. It also demonstrates how to handle the first line differently than the others.

    This is zero-based. The second time through the loop will say “Line number 1” if you use the exact setup below. If you need your  i  variable to be “1” on the first loop, just move the  i + 1 calculation above the If All Conditions Met Execute Actions and change the  i is 0  to i is 1. Alternatively you could start i as 1 and change the i is 0  to i is 1.

    Screenshot_2015-09-06_07-17-17

  • Tech Tips

    Detecting When You’re “Away” or “Back” in Your Keyboard Maestro Macros

    Your Mac knows the last time you moved the mouse or pressed a keyboard key. We can use this information in Keyboard Maestro to perform actions based on whether we’ve “gone away” from or have “come back” to our computer. I’m using this technique to set my status in Slack to “Away” if I step away from my computer for more than 10 minutes, and back to “Active” when I return. Here are a few quick examples that could use this same basic framework:

    • Automatically pause music if I step away
    • Show me a “Welcome back!” message when I return
    • Write the date/time to a log file the when I go away and when I return

    Setup your macro with a “Periodically while logged in” trigger. In the example here I’m using 10 seconds because I want no more than 10 seconds to pass before my system detects that I’ve returned to my desk. The macro isn’t very CPU-hungry so 10 seconds shouldn’t be problematic.
    Screenshot_2015-07-28_07-52-16

  • Development

    Disable Drupal’s default “user X has applied for an account” email

    By default Drupal sends an email to the site admin; it’s not editable (and you cannot disable it) from the account settings page.

    On a recent project I had to use Rules to send some emails when a user registers for an account. Because I was already sending emails via Rules, I needed to disable the stock admin email. Here’s a quick way to do this:

     

  • Development,  Tech Tips

    Easy Dummy Text using Python Faker and Keyboard Maestro

    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.

  • Development

    Private Messages – Moving “Delete” button into “Actions” select list

    By default the “Delete” operations will show as a button on Privatemsg‘s message listing page. There is an “Actions” dropdown that includes actions to “mark as read” or “mark as unread” so why not include “delete” there?

    Luckily the module developers included a hook to easily override the options. If you set the “button” property of the “delete” operation to FALSE it’ll render in the select list instead of as a button.

  • Development

    Allowing Users to Cancel Their Own Commerce Licenses

    UPDATE: I’ve written a contrib module called Commerce License Cancel to get the ball rolling to make this a community effort. Read on if you’d like to see how I got there.

    There’s been some talk in the issue queue for Commerce License Billing about needing a way for users to cancel their own licenses. Here are some pieces and parts that I’m using to achieve this. This is a work in progress and I’m really just posting here so I can provide a clean link in the issue queue. Sorry for the lack of detailed explanations; hopefully you still find this helpful.

    There’s already a method to “revoke” a user license. When you revoke a license, the recurring billing should close out automatically and the role granted (if it’s a licensed role) will be taken away from the user.

    The site I’m working on has just a few “membership plans” or levels that a user can purchase. For this reason, I could hardcode a few things. It’d take a LOT more work to make this stuff ready for the masses.

  • Development

    When Did Drupal Cron Last Run?

    Here’s a simple drush command to determine when Drupal cron (and node index cron) last ran:

     

  • Development

    Variable Types for Use in hook_rules_event_info()

    There is plenty of documentation out there explaining how to create custom rules events. What I had a tough time finding was a list of the variable types that are available for elements reacting on this event. I had seen examples of “text” and “user” but I really wanted to know what all of the types are.

  • Development,  Tech Tips

    Keyboard Maestro URL Handler (KMLink) – Introduction and Basic Usage

    Keyboard Maestro offers many ways to trigger macros, but unfortunately there isn’t a URL handler that lets you trigger macros via a URL. There are a number of keyboardmaestro://  URLs handled by the built-in url scheme, but executing a macro isn’t an option. If you’re interested in triggering macros via bookmarklets and Finder shortcuts, read on…

    I’ve written a URL handler that allows you to execute macros and pass variables to them. It’s a simple app that registers a URL handler to process kmlink:// links.