Applescript runs Macro a single time and then doesn't work anymore

Hey there,

i made a little script that opens a Google translate Page with input from an prompt.
It works well with the hotkey or via the palette. But when i try to run it with applescript

tell application "Keyboard Maestro Engine"
   do script "Translate"
end tell

it works a single time. If i want to call it again by applescript i get the error "do script found no macros with a matching name". The script still runs via the hotkey or palette but not with the script..

If the macro works at the background, it is a good macro.

Do you mean this?

You can quote AppleScript by starting with a line:

```applescript

and ending with the line:

```

My guess is your macro group is no longer active after you run the macro, and so the macro can no longer be found (only macros that are active can be executed with the do script "Macro Name" command).

Check the activation of your macro group.

it runs with "Run Selected Macro". But the applescript quoted above does only work a single time to run the macro.

@peternlewis i checked it. The macro group is still active :man_shrugging:

Add a Status Menu trigger. When you try to run the AppleScript, check that the macro is listed in the Keyboard Maestro status menu.

I tried that. At first its shown in the status menu and it works as usualy.
After some time it's no longer shown in the status menu - Thats the point when the macro is no longer triggered by applescript.

Thats very weird, since there is no other macro interfering with it at any time.

At that point, the macro is no longer active (either because the macro is disabled, or the macro group is disabled, or the macro group is inactive).

So I would look at the macro group settings unless you are actively disabling the macro or macro group via actions (which would show up in the editor).

So i think i figured it out.

i have an hotkey to show some macro palettes, the macro palette with the macro i mentioned shows up aswell.
While its shown the macro runs via applescript. But as soon as the palette is no longer visible the macro cant be triggered through applescript anymore.

So thats probably what you mean by "inactive"?

Anyway thanks alot!

This is inactive diabled macro palette:

This is an inactive disabled macro:

Well then it's not active :confused: the palette is just invisible but active all the time.. weird

You wanna use the macro but set it inactive diabled?
It's just like you wanna charge your phone but didn't plug the charger in the electric socket!

No. They are Disabled Macros and Macro Groups.

A Macro is active if and only if:

  • The Macro is Enabled
  • The Macro Group is Enabled
  • And the Macro Group is Active.

Active is a transient thing, related to the conditions in the macro group.

So apparently the Macro Group is only "active" if its palette is visible?

Stupid me, I mixed them up. :joy:

It depends on the Macro Group settings, but traditionally yes, for a macro group that shows a palette then it is only active when the palette is showing.

However if it is configured with one of the Always activated and shows… variants, then the macro group will always be active, even when the palette is not showing.

Don't feel that way. Macro Group and Macro Activation is a complex topic, and can be hard to fully understand. Maybe this will help: Macro Activation .

Thank you :blush:

Ahhh okay!

But thats kinda weird if it doesnt always work when its set to the normal "Always activated".

Anyway, thanks a lot!

Traditionally, any macro group that ever shows a palette is active if and only if the palette is showing.

So hiding a macro group palette is effectively deactivating it.