Looking for a quick way to extract appleScript from a (or multiple) macro and insert into a new script editor file

I am adding more and more macros to my very practical iPad hard palette via Luna display and the accessibility keyboard (link below)

I now find myself having to extract the appleScript from many macros → for each one, create, name, insert applescript and save to special directory a new file in script editor.

The remainder is done via the accessibility control panel and probably can't be automated.

I was wondering how much of this procedure can be automated.

To start off, is there any way to pick a macro and automatically extract its appleScript ?

thanks in advance for your time and help

Hello @peternlewis Would you perhaps have a suggestion ? thank you

Not sure whether you are using the AppleScript without modification or not but you can refer to a script file rather than the text of the script itself:


And if you need to modify the script with a new directory or file name, you can use a Keyboard Maestro variable in the script itself.


thank you for your reply.

My apologies for not being clear.

I am looking for a way to click on a KBM macro and somehow copy THAT MACRO'S appleScript trigger to the clipboard. Since I have to go through the process for many macros, I would prefer not to have to do it manually.

I use that script to trigger the KBM macro in my iPad hard palette (created via accessibility keyboard)

thanks again

Yes. I have a macro that does exactly that.

But before we go there, why do you want to do this?

If you just want to reuse the same script in multiple Macros, save the script to a compiled script file (.scpt), and use that file in the Execute AppleScript action.


I have just posted my script:

SCRIPT: Edit Script/Sub-Macro in Selected KM Action


thank you for the post and macro.

I think that there is a misunderstanding.I am referring to the appleScript which triggers the macro, not the appleScript of an action in the macro.

Example: I am creating a scrivener specific accessibility keyboard aka KBM hard palette using an old iPad.

Each button in the panel triggers a specific apple script via a .script file which contains that macro's TRIGGER appleScript.

Since I have many buttons to create it becomes a bit tedious to click on each macro → copy its trigger appleScript → create new .script file and paste AppleScript into it → put in the right directory.

I wrote a macro to do the following : create new .script file and paste AppleScript into it → put in the right directory.

What is am missing is some way to automatically copy the trigger AppleScript to the clipboard when I click on a macro in the macro list. In other words, I would like to click on the macro → run a macro or script → end up with that macro's trigger AppleScript in the clipboard. After that I am fine.

thanks in advance for your time and help

Hey @ronald,

Since the script for running KM macros via AppleScript is always the same, all you need is a way of grabbing a macro's UUID for the do script part, which KM already provides via the Edit > Copy menu, after which it's fairly easy to assemble the script trigger in KM. Here's one way to go about that:


brilliant ! thank you so much !!!

1 Like

Hi, I don't understand why you use these 2 actions which I notice you regularly use in macros.

The CLIPBOARDSEED function is a way KM provides to check whether the clipboard's contents have changed or not. The first action sets a variable to the clipboard seed's current integer before performing the copy operation, then checks the clipboard seed against that variable after the copy operation has been performed to ensure that the copy operation was successful. This sort of check is already built in to KM's Cut and Copy actions, but we can also use it manually this way to ensure that the clipboard's contents will be what we want them to be whenever a macro needs to copy something.

1 Like

crystal clear. thanks very much

1 Like