How to set a variable?

I can't seem to find a way to set a variable that doesn't involve my clipboard or scripting. The former doesn't seem efficient, and I have no idea how to do the latter.

I want to run an "If" action, and if it's true, I want variable X to be set to Y, and if not, I want it set to Z. I feel like a dummy not being able to figure that out, so help me please!


Basically you want to do it like this:


Conditionaly Setting a Variable.kmmacros (2.1 KB)

I recommend to have a look at the KM Wiki. It has plenty of useful information, for example this.

1 Like

@Tom has answered your specific question, but it sounds like you are very new to KM.
So, I'd suggest the following:

Getting Started with Keyboard Maestro

  • Read the Quick Start.
    • This is essential to become familiar with KM terminology
  • Do the tutorial (Help ➤ Tutorial) in the KM Editor.
    • Gives you a live walkthrough of creating a macro in the KM Editor
  • Review/Browse the Available Macro Actions
  • For Help with an Action in your Macro, click on the gear icon at the top right of the Action, and select "Help"
  • Search the Keyboard Maestro Wiki for detailed help.
  • Start small, and grow your macros organically.
  • Be prepared for some trial and error in the beginning.
  • Make good use of this Keyboard Maestro Forum
    • Search for existing macros
    • Post your questions/issues if you get stuck
1 Like

Silly me. There it is. "Set Variable to text" sounds to me like I'm fetching a variable and typing it out as text, and I see now that I was wrong. Thanks for this!

Thanks! I'll go through all of that!