Hello Folks!
I need a little help from you. I have a mcName variable that I'd like to automatically populate and search within the Trigger Macro by Name action. I've searched and tried different methods but nothing, that I was able to find in the forum, worked. I'm able to use variables in my other macros. I'm thinking there is something special or unique going on while using this action. Please assist.
Thank you JMichaelTX for verifying and responding to this. I was trying all the methods I thought I learned before asking. I will check out the DanT's macro.
Thanks. I took another route. The window was behind a palette so I used the Conceal Macro Palettes action to begin before the window appears. Once done, I used the Reveal Macros Palettes Action to reset it.
The last thing on this subject (for now) is once I pass the variable to the Trigger Macro by Name window, is it possible to automate the return key to enter in that window? I've tried the Return Keystroke action and AppleScript System Events Return script to know avail.
I just want to pass the variable to the Trigger Macro by Name and Enter without my interaction.
I don't understand - if you know the macro you want to execute and the trigger value you want to send, why are you using the window at all? Why not just execute macro directly via AppleScript?
Why? Because I was laser focused on the wrong path of just working with the Trigger by Macro Action. I’m not a programmer or scripter. I admit that I’m just flailing in the wind sometimes. For many of my solutions, I know that there has to be better or more efficient ways of using techniques. Thanks for the suggestion. When I get home, I will do research on how this can be done. Hopefully, it’s just a matter of:
tell “Keyboard Maestro Engine”
do script “mcName”
end tell
.... or somehow grabbing the UUID from the mcName. I have two wiki pages that I will focus on. I’m sure I can figure it out or ask the right question. Funny how when you asked the question, lightbulbs started going off.
Any other suggestions or techniques are appreciated.
Ok. I have been defeated this time. I've been on so many Forum pages that I've confused myself. I'm asking for help.
I have a KM variable called (mcName). I'd like to pass that mcName variable to AppleScript do script. Yep, I looked at a few AppleScript pages on here and my syntax/format is jacked.
I'd like to this in the Execute AppleScript action:
tell "Keyboard Maestro Engine"
do script "[my mcName Variable]"
end tell
The current value for the mcName Variable is MegaMillions. This MegaMillions macro happens to be a global macro that runs from anywhere.
However, it didn't work, because the variable didn't pass through.
So I went down the rabbit hole, saw a post from Peter (a version 7 post I think) and did this:
tell application "Keyboard Maestro Engine"
set myNam to getvariable "mcName"
do script myNam
end tell
NOPE. Didn't work. I'll spare the 20 or so variations and a few hours. Now, I'll humbly ask for help.
Please put me out of my misery. Can you explain how to do this? I promise not to ask for help for another 2 weeks or so.
that should have worked, provided that the KM Variable "mcName" is defined AND has the name of a valid macro.
So, from the macro action area, where you assign a trigger, there is dropdown labeled "Or by AppleScript". For example:
tell application "Keyboard Maestro Engine"
do script "Use One Image to Find Another [Example]"
end tell
You might check your actual macro in this area to confirm the name.
Try this macro. It will display an error if "mcName" is NOT defined.
tell application "Keyboard Maestro Engine"
set myNam to getvariable "mcName"
if (myNam ≠ "") then
do script myNam
else
set currentApp to path to frontmost application as text
tell application currentApp
set msgStr to "INVALID Macro Name"
set msgTitleStr to "Trigger Macro via AppleScript"
display dialog msgStr with title msgTitleStr ¬
with icon stop
end tell
end if
end tell
Thanks for your time JMichaelTX. I quit the engine and restarted it. Miraculously, it worked. I used your macro as well. No errors came up and it worked fine as well. I'm still scratching my head though because I'm not confident why it worked. Maybe something triggered with the drop down "Or by AppleScript" area. Doesn't make much sense.
Something weird happened though. At first it was just plain text, but then it compiled (You know, with the formatting and colors). After that, it worked.... (shrug).
In two weeks, I'll ask how to properly syntax this one as well but for a single macro with the mcName variable:
tell application "Keyboard Maestro Engine"
set enabled of macro group "Macro Group Group Name or UID" to true/false
end tell
However, you helped with the other one so I can wait until my probationary period is up! Plus my head hurts from this ordeal.