• 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,  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,  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.

  • Tech Tips

    Delete Last Command from Bash History

    If you’re like me, on occasion you accidentally (or sometimes purposefully) include a password in a command. Until recently I would execute history , find the offending command’s number, then do a history -d NUMBER . It is kind of a pain.

    The following deletes the last item in your bash history:

    You can create an alias for this, type it manually (umm, no thanks), or, as is the case for me, create a Keyboard Maestro macro for it. Here’s what my macro looks like:

    img20141208190438

  • Development,  Tech Tips

    “Create Evernote Note” from Chrome Tab using Keyboard Maestro

    Here’s an example of a macro that creates an Evernote note out of the current Chrome browser tab. My goal was to just throw the current page into Evernote with its page title as the note title, and its URL as the source URL.

    Step 1: Build the macro as shown below. I encourage you to tweak the Applescript, but you may want to test with the Applescript editor first.

  • Development,  Tech Tips

    Keyboard Maestro URL Handler – Link Injection

    Introduction

    This post outlines some advanced usage of the Keyboard Maestro URL handler (KMLink).

    A few weeks ago I was automating some Chrome form filling with Keyboard Maestro. It occurred to me that the perfect trigger for what I was doing would actually be a simple link within the Chrome webpage itself (or a simple bookmarklet); when the link/bookmarklet is clicked, the KM macro is executed. How about a little backstory before I get to the “here’s how to do it!” ?

    We use a project management system called ActiveCollab. It’s a great piece of web-based software, but often simple things take several steps. When I want to quickly mark a task as “Due in 2 business days” (which I need to do very often) it’d be whole lot nicer to click a link to set this, than to have to go to the edit screen, pull up the date picker, think about what two business days from today is, click that date and submit the form. Sure, I could write a module for Active Collab that would do what I want, but Keyboard Maestro provides me with much more freedom and I can build it in minutes instead of hours.

  • Tech Tips

    Keyboard Maestro – It’s the Little Things

    I’ve been using Keyboard Maestro to make myself more efficient. Even the littlest things can (and should) be automated to save time.

    I spend a good portion of my day navigating directories in iTerm. Often I find myself jumping up a directory (back) and then listing the directories to get my bearings.

    In about 30 seconds I made myself a quick hotkey that will be active during iTerm sessions (it’s within my iTerm group, which is only active for the iTerm application) and will perform both operations (cd .. and ls). I mapped this to CMD-u which I think of as “up” so it’s easy to remember. Notice there is a return (linebreak) after the ls; this will simulate hitting return, which will execute the preceding commands. I could have added a return keystroke action, but this is just faster and requires less actions.

    I encourage you, if you’re a KM user, to think about the little things and figure out where you could shave off keystrokes, mouse clicks, etc. to make yourself as efficient as possible.

    km-cd-ls

  • Tech Tips

    Keyboard Maestro – Paste into Vim (with formatting)

    Vim users frequently run   :set paste  and :set nopaste . Using paste mode makes it simple to paste text while maintaining whitespace, but some other aspects of Vim are reset in paste mode (e.g., autoindent and smartindent). I’m sure there’s a way to make it easier to flip back and forth within Vim (via .vimrc), but if you want a universal way to do this, regardless of the Vim settings that are in place, you may find the following Keyboard Maestro macro helpful.

  • Tech Tips

    Keyboard Maestro – Simple GUI for a Command-line App

    Keyboard Maestro is now an integral part of my workflow throughout the day. I’ve found one particularly helpful use for it is to build very simple GUIs for command-line applications. In the example here I am showing how I use Keyboard Maestro to build a simple GUI for a Python script I wrote called dummyimage.py [see project on github]. Here’s the official description of the script: