Inactivate action after it has fired

HI all. Hope you are ok, even in these stressful times!

I wonder if there is a way to inactivate an action ones it has fired. Im using a "If all conditions met execute action". And everything runs as intended. But the action can't fire twice... and as I have made the macro, it fire several times. I can't figure out how to inactivate a specific, action once it has fired within a macro. Any Apple script or similar that you know of that would help me out on this matter?

All the best.

I'm not aware of any way to inactivate/disable an action during a macro's execution. But if you were able to post your macro somebody might have an idea for a workaround.


Yes. Im creating some Keynote automation, where the variable is the same as the number of a keynote slide. Well within a slide there are several "animations" and since the slide still is at lets say, "Slide 9" the macro triggers the action several times instead of one time...

If I could specify an animation action within the keynote slide instead of the number, or disable the action after it has fired it would both be a solution to this problem of mine. Here is the macro as well : )

KEYNOTE Automation.kmmacros (8.0 KB)

Ok I'm going to preface this with I don't use Keynote... which basically means I have no clue what I'm talking about :laughing: BUT... this might work for you (I also took the liberty to make a few adjustments to your AppleScript and changed the If actions to a Switch action).

Since I don't know much about Keynote, I wouldn’t know how to accomplish what you need with AppleScript. But within the Switch action I use an If action (on slide 9 only, just to show you an example), that will only trigger the action if it has not been triggered already. This is accomplished by it setting a variable the first time it triggers, and then it slide 9 is repeated (due to the animations), the If action will see that the variable contains yes and not trigger that action again.

Take a look at it, and see if it would work for your needs!

KEYNOTE Automation.kmmacros (8.5 KB)

Macro screenshot (click to expand/collapse)

1 Like

Works great Chris!! Thanks a lot... The switch of Variable is a much better tool for this : D
The only part I cant figure out what its doing is the debug_actionRan. It feels like the "Switch of Variable" already fixes the duplication of actions. I took it out of the macro and it still works as intended. But would be nice to understand the mechanism you made.

Glad it's working for you!

The variable is set after the action runs. Which means that if the macro is triggered again, and it's the same slide, the If action will see that the variable exists and contains "yes", and will skip the action. Since that's a global variable (I append all my global variables with debug_ when I'm building a macro to make it easy to clean them up afterwards), it still exists in your KM library, and the If action is seeing it and skipping the subsequent action. But eventually you will want that action to trigger, like the next time you’re doing a slideshow. Which means you need to delete that variable at some point, perhaps when you're completely finished with the slideshow. Otherwise it will always be there, and that action will never trigger again.

So perhaps you have an 'end of slideshow' macro that closes apps/windows or whatever, and you could delete that variable at that time so the next time you're doing a slideshow, it doesn’t prevent the action from executing the first time you're on slide 9.

Hope that makes sense :sweat_smile:

Edit: One more note... you'll probably want to prepend/append that variable with some identifier to indicate which slide action was already ran, that way if you have multiple slides that have animations (and therefore that same If and variable combination), the other slide's actions aren't impeded.

For instance, you could name it something like keynote_actionRanSlide9 to show that's it's a variable for your Keynote macro, and it's for slide 9 specifically.

Cool Chris. Thanks for the explanation... I will tinker around with this macro to get it all running the way I want it to, based on your tweaks!!

You're welcome! Let me know if you need any more help with it :grin: :+1:t2: