Point and Click with Keyboard Maestro


Point and Click with Keyboard Maestro
Mac Tip #449, 11 August 2010

Keyboard Maestro lets you set up sequences of actions, called macros, and then does them for you. For example, I can set it up to start an application, enter defined text in the right place, click and carry out some menu actions. And so can you. Here are some guidelines and tips.

Please read Turn 100 steps into 1 with Keyboard Maestro for a refresher on the basics of Keyboard Maestro.

Use the coupon MacTips for a 20% discount on Keyboard Maestro. [Updated] This offer expires at the end of October 2010. It’s free to test the software.

httpv://www.youtube.com/watch?v=Luw3vStW6rY

Please subscribe to the MacTips channel. Or just visit this video on YouTube, leave comments and rate it, as that helps spread the word about the MacTips.

An example sequence

In this Tip I’ll use Keyboard Maestro to open a web browser and go to an URL, then to copy the URL from the browser, open Network Utility and run a Traceroute — all with one click.

My purpose is to show how to use Keyboard Maestro to open a program, click in specified places, insert text in a field, and get information from one program into another.

The all-important Pause

Keyboard Maestro Pause action.

Keyboard Maestro Pause action.

As human beings, when we work through a sequence of actions, such as opening a web browser and typing in an URL, we know when and how long to wait before we take the next step. A web browser may open instantly, or there may be some delay — perhaps if our computer is busy on some other task.

One common reason for macros to fail is because everything happened too quickly. We need to build in delays at certain points, to make sure the previous step has been completed before trying to do the next step.

When you add Actions to a macro, insert a Pause action from time to time, and set it to maybe 5 seconds or longer. Then in testing see if you can reduce it to a shorter pause.

Macros can include other macros

Move and resize a window.

Move and resize a window.

I have a handy macro that moves and resizes a web browser window. I just like my windows tidy. But moving a window is also a handy trick when you need to click in a specific place.

By moving a window to a defined location, you know that clicking at certain co-ordinates will always hit the target. If you don’t move it first, then the window may not be where you think it is — perhaps you moved it some other time by accident — and your click may miss.

Open Firefox and go to an URL

Keyboard Maestro go to an URL.

Keyboard Maestro go to an URL.

I set up this sequence of actions to cause Firefox to open my MacTips website:

Activate Firefox
This either opens Firefox if it’s not already open (which may take a few moments), or brings it to the front.
Pause for 3 seconds
If Firefox isn’t already open it may take a few seconds to start up. On my machine 3 seconds seems to be long enough. On your machine it may open more quickly or more slowly.
Execute a macro
This is my macro that moves the window to the top left of my screen: the co-ordinates for the top left corner of the window are 1 pixel across and 22 pixels down. The menu bar takes up 22 pixels. I like that 1 pixel of space on the left too. This macro also sets the size of the window to the dimensions I prefer: 1155 pixels wide and 800 tall.
Type the Command (⌘) T keystroke.
This makes a new Tab, so it doesn’t disturb any web page I might already have open.
Type the Command (⌘) L keystroke.
This puts the cursor in the Location Bar, ready for the address. Making a new Tab should have put the cursor in the right place. This is just in case it didn’t.
Insert Text by Pasting
This enters the URL I specify in the Action, in this case: http://mactips.info.
Type the Return keystroke.
This causes Firefox to attempt to go to the URL specified above.

With any luck, the web page will soon be displayed in the Firefox tab.

Test the macro

My macro worked and called up MacTips.

My macro worked and called up MacTips.

Now use the trigger you’ve set for the macro and see if it works. Remember: the macro relies on putting the cursor in the Location Bar in Firefox so don’t click elsewhere while the macro’s running. Just wait.

If the macro doesn’t work, look to see where it failed. You may need to add more or longer pauses. For example, if it started Firefox but didn’t even put the URL in the Location Bar, maybe Firefox wasn’t ready in time. Add a longer pause before trying to paste in the URL.

Run a Traceroute

Sometimes if you can’t reach a website you might use Network Utility to run a Traceroute — it helps identify where the problem is. This next macro:

  1. copies an URL from the browser
  2. opens Network Utility
  3. calls up the Traceroute tab
  4. pastes in the URL
  5. edits the domain slightly
  6. sets the Trace running.

Caveat: I assume the URL is in this form: http://mactips.info/. If it’s more like this: http://mactips.info/2010/08/turn-100-steps-into-1-with-keyboard-maestro then my editing won’t be sufficient.

Run a Traceroute.

Run a Traceroute.

Get the URL
Activate the browser, type the Command (⌘) L keystroke to put the cursor in the Location Bar, and then type the Command (⌘) C keystroke to copy the URL. Note: The Copy Action is a quick way to get the Command (⌘) C keystroke .
Activate Network Utility and place window
Activate Network Utility and pause to give it time to start, then move the window so its top left corner is placed at 6 pixels across by 22 down, so we can place subsequent clicks exactly, and pause again to give the window time to move.
Click on the Traceroute tab
Click at the correct co-ordinates (on my screen, and after the move in the previous step, that’s 366 pixels across and 48 down). This activates the Traceroute tab. I couldn’t find any keystroke or menu item to call it up, so clicking was the only way.
Paste and edit the URL
The URL I copied from the browser was: http://mactips.info/, but Traceroute doesn’t like that. After pasting in the copied URL I need to delete the trailing slash by pressing Delete. Then pressing Option (⌥) ← (left arrow) puts the cursor after the http:// portion. Press Delete 7 more times to remove it. Note: The Paste Action is a quick way to get the Command (⌘) V keystroke .
Press the Trace button
Finally Keyboard Maestro can press the Trace button to initiate the trace.
Traceroute.

Traceroute.

How to prevent frustration and annoyance

It takes a lot of writing to describe anything step by step. It may seem like a lot of hard work to set up a macro, and it can take a while. You have to think through the steps. Luckily Keyboard Maestro can help by recording a macro for you, but more on that later.

If you spend 10 minutes setting up a macro that will save you 1 minute per day all year (6 hours over the year!), then you’re winning after the first few days.

And for me it’s not always about time savings either. It’s more the sheer annoyance of having to click a dozen times to do something that’s quite mindless really. One of my macros saves me 5 tedious clicks on a single web page I visit every day. I love it!

Use the coupon MacTips for a 20% discount on Keyboard Maestro. [Updated] This offer expires at the end of October 2010.

Have you used Keyboard Maestro yet? Tell us about your experiences in the Comments. Have you found any great Tips? Share them with us.

Related posts

[wpzon keywords="pressure cooker" sindex="PCHardware" snode="1232597011" sort="salesrank" listing="8"]

5 Comments

  1. Bakari said:

    They both seem to do the same thing. Many Mac users seem intimidated by automation programs, but they’re really not that difficult to learn and use. And their really great time savers.

    I’m not sure if KM has this feature, but many of my QuicKeys macros activate/perform actions when an application is launched or when it’s longer in the forefront. For example, I have macros that will automatically quit a designated application when it is not used (not in the forefront) for 10 minutes. So if when I open iCal, I leave it open and QuicKeys will close it out for me after 10 minutes.

    QuicKeys also has its own menu bar for each application. So instead of having to assign and remember lots of keyboard shortcuts, I can simply activate macros for apps from the QuicKeys menu bar.

    Anyway, I‘m going through the tips on your site. You have great tutorials here. I’ll be visiting again.

  2. Bakari said:

    Looks like you like Keyboard Maestro the same way I like QuicKeys. I try to come with macros for nearly everything I do on my Mac. I look forward to more of your tutorials using KM.

  3. Gary Watson said:

    Hi

    Sorry, I find the macros in Keyboard Macros very confusing.
    1. When I setup the action “Resize front window” it says percent, not pixels as your demo describes
    2. How do you see a floating palette? It does not seem to be in the menus or in the help section when I searched

    Thanks

    • Miraz Jordan said:

      Hi Gary,

      for the Resize window action, it uses percent as default. However, on the next line note the small arrow beside the words “Scale size by”. Click that arrow and choose “Resize to” from the pop-up menu. Then you can enter a fixed number of pixels for width and height.

      The Floating Palette only appears once you’ve selected it as a Trigger. For the Trigger choose “Macro palette entry is clicked”.

Comments are closed.



Top