Best Way to Fire a Macro in the Background

Hello Everyone,

Quick question which I could not find an answer to.

I've got an AppleScript that launches a KM macro that downloads some images then asks me for input.

Whether I run the macro separately as a step before my main AppleScript, or from inside my AppleScript, there's a delay as the KM script that downloads the images finishes.

I'm trying to find out if I can run this script in the background, so I can immediately move on to typing my input without a delay.

Is there a good way to make a KM macro "fire off" then immediately continue without waiting for it?

Follow up question, too, if I could. I'm using the Click at found image but it's a hard to get it 100% right.

I found the Click Google Chrome Link by name command and wondered if it somehow indexed the links and would know the name "Create Post" (which is what I'm trying to click on).

Is that how this works? Just running it with Click Link: Create Post doesn't seem to do anything sadly, so either I'm doing something wrong or the website (SocialPilot) uses JavaScript etc.

Hey Peter,

You're not being at all clear in your description...

  • Where are you running this "main" AppleScript from?
  • Firing a macro and not waiting for it only requires a macro and a trigger.
    • But that's not what you really mean is it?

You want your macro to be able to perform a separate process and not have to wait for that process to complete before moving on to the next step – yes?

I suspect that using an Execute a Macro action with the “Asynchronously” flag set is what you are wanting:

image

But this may depend upon other factors.

You can also call a macro from AppleScript and ignore responses:

ignoring application responses
   tell application "Keyboard Maestro Engine"
      do script "00000000-5547-4458-1111-256AEEE22800"
   end tell
end ignoring

Keyboard Maestro shows you how to do this when you select “Or by AppleScript” as a trigger, but it comments-out the ignoring… statements.

-Chris

1 Like

You read the docs?

“The parameter can be an XPath or the title of a link.”

actions:Click Browser Link [Keyboard Maestro Wiki]

What you see as a link's name isn't necessarily what it takes to address it.

You tried the pop-up link menu in the right side of the action?

If that doesn't work then you'll probably have to inspect the page code with the developer tools and use a Execute a JavaScript in Google Chrome action.

Although – you might be able to use inspect and then copy the XPath to paste into the click-link action.

1 Like

Thanks! That sounds like what I need!

In testing I was running the AppleScript from Script Editor, but in practice I will be running the master AppleScript from a KM macro itself.

I'll test these out tonight.

1 Like