Is It Possible to Programmatically Add in Checkboxes to an Input Form

Hello

Is it possible to programmatically add in checkboxes to an input form?
I have the number of checkboxes I want as well as the label next to the checkboxes.
I also like to respond to each individual checkbox as well.
I wanted to ask first just in case I spent relentless hours trying to test something that couldnt be done in the first place.

Ben

Nyet.

You could write a macro to do it, but it would be a pain and likely would be a bit fragile.

The best way would probably be to compose the XML of the user-prompt action and then insert it in the working macro via AppleScript.

That would be doable with the above method.

What do you mean?

ok so i managed to separate the xml into three parts. Begin, Process and End.
The process is where I concatenate the number of dictionaries where dictionary looks like this

  <dict>
    <key>Default</key>
    <string>0|1</string>
    <key>Type</key>
    <string>Automatic</string>
    <key>Variable</key>
    <string>Choice</string>
  </dict>

and then I merge that all into one variable along with Begin and End and named it "merged"
and then I tried to get applescript to process it but it wouldnt work.

tell application "Keyboard Maestro Engine"
set clip to process tokens "%merged%"
end tell

I hope the devs make a better solution for us cos the XML format could change and id hate to change every one of these XML forms manually.
Ben

I'm not very clear on what you're up to but you can construct a variable consisting of HTML form tags as needed and use JavaScript to display that variable in a Custom HTML Prompt.

I do that to construct select form elements in a few of my macros, like Mirror Mirror, which shows the general approach.

A "Prompt for User Input" form, not a HTML Input form.

What makes you think that could possibly work? Process Tokens has nothing to do with creating a macro or an action via AppleScript.

See this post for an example that shows how to create a macro with XML and AppleScript:

Macro to Create a Text Expansion Macro from the Selected Text

See this for an example of how to create an action in the working macro via the same method:

Keyboard Maestro Editor ⇢ Paste Dated Attribution Action v6.01 Macro - #11 by ccstone

1 Like

For anyone who wants to know the answer to the above.
Its here.

That’s how to execute an action by running XML via AppleScript – NOT how to insert an action in a macro via AppleScript...

your right

learning keyboard maestro is one, rust is another and now i have to learn applescript.
All these things ive ever asked for has done before by someone else so why is it so difficult to find it the answer?
Annoyed.

When I find the time i'll try to do it via Applescript unless you have a solution that works right off the bat.
I have 1 new macro that is so hard to maintain that ive literally shot myself in the foot.
Ive just learned how to read and write JSON values directly. Next is Applescript.

I search up applescript tutorial on the keyboard maestro website only to find the bare basics. When I open up someone elses applescript, im like "Where did that come from? What is that? !!!!"
Annoyed. Lack of documentation for applescript on keyboard maestro to fully absorb it and get into the flow.

The only way forward is for me to write more in Applescript cos the way im going is causing me headaches with actions.

I thought engrouping actions would help simplify and improve flow but then I realised that it cant cos I find myself expanding groups so many times its ridiculous.

I will try to duplicate the macros and shrink one of them down without losing function so that I can get it done in less actions (a mix of applescript and actions). For me, thats a big task cos I dont even know Applescript.

For anyone else that reading this, can someone please point to some really useful applescript tutorial with KM. Dont send me to the basics.

Ben

Personally, I prefer JavaScript for Automation (JXA). It sounds like you know javascript, so this might be a better option. There isn't a lot of documentation, but you can at least find some if you look. And there's examples on this forum.

1 Like