A Compact Way of Managing Input Forms Based on Conditional Statements

Hey guys,

I wanted to share this with all those that could benefit from it.

An Illustrated comparison of input form actions displayed based on conditional statements such as if statements verses doing it via XML and Applescript. Compare the size difference.

This approach can be very useful when you know your forms won’t need to change.

With Actions:

With Copy as XML and AppleScript:

Applescript code:
Execute an AppleScript.kmactions (1.2 KB)

To be able to achieve this:

  1. You need to download and install VSCode.
  2. In keyboard maestro, Select the form you wish to compact, right click and, select Copy as XML. Create a file inside VSCode with a .xml extension and paste from clipboard (CTRL + V on PC)
  3. Delete everything above the first <array> and below the last </array>.
  4. Select all, Hit Control Shift P if on PC and type in Join Lines.
  5. Put a ' at the very front of the first
  6. Paste that into a variable action then remove the apostrophe.
  7. Use or edit the AppleScript I’ve provided to suit you.

If you ever need to change the input form, simply copy that XML code that is in that variable
and immediately paste from clipboard. The form will automatically display below. Edit it, copy as XML and repeat the usual process. You can also paste that XML code in a XML prettier or formatter so that its easier to reedit.

Id also highly recommend you download Script debugger. You can paste your applescript code in Script debugger. From KM, multi-select the variables or forms to run then immediately after, run the Applescript code from Script debugger. It is seamless. Managed to fix my Applescript code this way.

Hope this is useful.

Ben