If macro was called recently (1 second ago), do something else?

How can I do this?

I can't really find anything on how I can make this. In my case I want a simple macro that if I have not called the macro before, it would do this:


But if it was called earlier, it would instead do this:


So I can effectively call the macro twice if I want to do the second part with the Insert text by pasting.

Can I do this?

Hey @nikivi,

I don't know if this is the best way to go about this, but here's one that works (change BBEdit to iTerm first, obviously):

edit: karabiner.kmmacros (5.9 KB)
45 PM

1 Like

This is a relatively simple way to determine how long since the macro is last executed - just track it in a variable.

Note that the variable needs to have a valid value for the condition to make sense, so you might like to include a test for “The variable 'Last Runt Time' is/is not empty” to handle the case if the variable is missing or deleted. In any event, it will sort itself out after running it once.


Thank you. This works really well.

I just logged in to suggest using a variable. But when Peter himself guides you, what more can you add? :grinning:


1 Like

Believe me, people often come up with better solutions than me!