The macro is does not trigger the macros it intended to.
Basically any of the items on HTML menu that are clicked should be checked for "clicked" = 1 condition and the ones that clicked should run the macros.
The code I gave you in your other post was from my plugin action and you’ve tried to use it in an execute AppleScript action which is why it isn’t working.
The line
set _Macro to system attribute "KMPARAM_Macro" as text
is incorrect in that context so you have to revert to what you had previously
set MacroToRun to getvariable "VarName"
but inside the tell application "Keyboard Maestro Engine" like this
tell application "System Events"
with timeout of 36000 seconds
tell application "Keyboard Maestro Engine"
with timeout of 36000 seconds
set _Macro to getvariable "VarName"
do script _Macro
end timeout
end tell
end timeout
end tell
I'm not at my Mac so can't test for you but hopefully it will work as intended.
Alternatively - install the plugin action I posted (the zip file) and use like any other KM action. It's much neater and you can use it with any variable! Here's an example of how I use it:
Can’t do that as I’m not at my Mac - remember?
No. If you assign VarName to *%Variable%local_A1% then it will equal 1 but only if local_A1 itself contains 1. Just look at your Set Variable action - at the bottom it has local_A100 -> local_A100 which shows what VarName was last set to when you ran the macro; it’s clearly not what you are expecting.
BUT - I’m not familiar enough with Custom HTML Prompts (if that’s what you’re using) to be able to advise you on getting values from them into KM variables.
I can guarantee that the plugin works - well, after 6 years using it myself I’m pretty confident on that, which was your original question. It’s now up to you to get the correct value into VarName.
This will not set the contents of VarName to 1 or 0 because it Is literally setting the actual text contents of VarName to the text "local_A1", "local_A2" etc all the way up to "local_A100". You can see this by the fact that the last value shown for VarName is "local_A100"
You are trying to make a dynamic Variable - which is not that simple to do in Keyboard Maestro. When I looked into this a while ago I ended up using a Keyboard Maestro Dictionary instead.
@Zabobon thanks for pointing out local_A1 vs localA1 - I've obviously missed it.
Also appreciate learning about dynamic variables. I've used an easier solution, as it was hard for me to comprehend Peter's dictionary use example right away.
Here is my latest implementation - both Dynamic Variables Names and Values seems to be working.
However I can not make the macro run based on dynamic variables name - neither via AppleScript, nor using @tiffle plug in.
But they are the names of variables containing “0” and “1”.
I’ve never used a variable whose name is the same as a macro (I didn’t even know that was permitted by KM) so I don’t know what KM will do with that.
I suggest you give your two macros other names like “MacroA1” and “MacroA2” and modify the action where you set VarName appropriately.
@tiffle, good point - I've rarely used the log, and forgot I can troubleshoot using it.
The error is that it does not find the matching macro, even though both macro and macro groups are enabled, it is similar error using your plug in:
2023-06-30 07:52:19 Execute an AppleScript failed with script error: text-script:85:105: execution error: Keyboard Maestro Engine got an error: do script found no macros with a matching name (macros must be enabled, and in macro groups that are enabled and currently active). (-1). Macro “###NextGen Menus” cancelled (while executing Execute AppleScript).