This AppleScript should toggle the enabled status of the macro name included in the macName
variable. It does require that the KM editor be running, but it doesn't bring it to the foreground. You could try using it in place of the Toggle Macro action.
tell application "Keyboard Maestro Engine"
set MacroName to getvariable "macName"
end tell
tell application "Keyboard Maestro"
if enabled of macro MacroName is true then
setMacroEnable MacroName without enable
else
setMacroEnable MacroName with enable
end if
end tell
But since the macro name has to be exact, or it won't work, I'd recommend something like this that lists all of your macros with a list prompt and lets you type to select the one you want, which should eliminate the need to type it exactly yourself:
Choose Macro to Toggle from List.kmmacros (3.0 KB)
It lists every macro by default, but you can filter it down further to only show macros from a specific group if you want by modifying the initial AppleScript like this:
tell application "Keyboard Maestro"
set MacroList to name of every macro in macro group "Global Macro Group"
end tell