Reloading a macro into RAM mid-execution?

I apologize if some of my terminology is off here. I am trying to construct the following macro:

  1. Prompt for user input.

  2. Execute subroutine to dynamically generate another user prompt based on user input from the initial prompt.

  3. Execute dynamically generated prompt.

I have this entirely constructed, but with one problem–step three's action was loaded into RAM at the beginning of the macro execution, therefore the dynamically generated user prompt will not populate until the next execution. All this to ask: is there a way to force the KM engine to reload a macro into RAM mid-execution?

Please let me know if I can clarify anything. Thanks!

What happens if you put Step Three in a subroutine or a sub-macro that you call from the main macro? Does it still pre-load?


Yes, I have been calling step three with an "Execute Macro" action, and it still preloads, unfortunately. I also tried executing from an AppleScript to no avail.

Grasping at straws here, but if you set it to run asynchronously, does that work?


Thanks for the idea! I just tried running step three asynchronously, and enclosing the whole macro within another macro then running that asynchronously–still no dice.

Oh well. Time to ask @peternlewis if there's any way to do this? Possibly maybe using XML of actions, and editing programmatically? Not sure though.


I figured Peter might be the only one with a definitive answer here :thinking: I am creating the dynamic prompts by modifying an XML with variable input, and then importing the XML via AppleScript.

I've attached a test package for anyone interested. "User Prompt - RUN ME" replicates the three steps in the initial post.

Dynamic User Prompt Creation – Test Package.kmmacros (30.4 KB)

1 Like

Check out what's been said in this forum previously

Past my bedtime here...

1 Like

Can you share specifically what needs to change about the prompt? XML jiggerypokery might not be necessary, depending on what you're after.

I have no idea what you are doing, but @AlexGerbrandt’s suggestion would be my suggestion - if you want to create a dynamic action, create it’s XML and execute that via AppleScript.

I'm not sure if you will love my idea or hate it, but I have a totally different way to solve your problem. Try this....

Enter N values Macro (v11.0.2)

Enter N values.kmmacros (2.7 KB)

Here is what you get with its default value of 5:

@noisneil I am generating various checkboxes/menus/text fields/buttons on a dynamic basis. I'm happy with the implementation, but check out the package below if you're interested. I would love to know if there is a way to do this without the XML > AppleScript import process.

Hi @peternlewis, I think the primary quandary here is not the XML editing/macro importing, but rather whether one might be able to run the newly imported macro from within the same execution during which it was imported. Any ideas there?

@Airy, I definitely don't hate this idea! However, it solves only about a quarter of my problem. I have never used the prompt for snippet action before. This would be the perfect solution if it supported custom checkboxes, menus, added buttons, etc.. I love that you have more flexibility over the prompt layout with snippets. @peternlewis any chance this functionality could be added to the snippet action in the future?

Thanks all!

This might be the wrong track, but instead of trying to build a custom Prompt for User Input on the fly, why not just create a Custom HTML Prompt? They can have all of those items (it's just HTML, after all), and they can return their input to the macro.

No need for XML real time injection, just gather your data, pass it as inputs to the Custom HTML Prompt, then get the results back when the form is submitted. It'd take some HTML/CSS setup work, of course, but it seems easier to me than making a self-modifying macro :).


I understand and agree with you that those features would be nice. But when I wrote my post I didn't see any mention of those requirements in your original post. You simply said "user input", you didn't mention buttons, menus or checkboxes.

Even so, my idea might help some people with similar problems, so I'm still happy with it.

You would not import any macro.

You create the XML and then execute it as an action in the AppleScript with the Execute an AppleScript action.

The executed action will be in its own instance, so you wont be able to use local/instance variables.

@Airy –my apologies–I didn't intend to put down your response. I'm very thankful you pointed out snippets to me. I'm looking forward to using in the future! Take care!

@griffman, you've unlocked a whole new world of possibilities for me! Thank you! Off to polish up on HTML and CSS now...

@peternlewis – Aha! Excellent, this is exactly what I was looking for!

1 Like