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 Copy as XML and AppleScript:
Execute an AppleScript.kmactions (1.2 KB)
To be able to achieve this:
- You need to download and install VSCode.
- 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)
- Delete everything above the first
<array>and below the last
- Select all, Hit Control Shift P if on PC and type in Join Lines.
- Put a ' at the very front of the first
- Paste that into a variable action then remove the apostrophe.
- 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.