Simple Conditional on off (if then else)

Hi everyone, I want to create a simple conditional
statement that activates based on a variable,
deactivates, and then repeats the process. I plan to
achieve this using an "if-then-else" action.
I maked this:

but doesnt work correctly, thank you for the help.

Hi, @Angelo_Ramirez; welcome to the Keyboard Maestro forum.

Since you are a new forum user, I'm going to refer you to three references that will make your time here much more efficient:

With each execution of the macro, are you trying to toggle global variable Bart from 2 to 1 and vice versa? That is, undefined -> 2 -> 1 -> 2 -> 1...

If so, the actions you displayed seem to work. I reproduced and tested them:

Download: Bard Variable.kmmacros (5.6 KB)


  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.5.1 (22G90)
  • Keyboard Maestro v10.2

1 Like

As @_jims says, these actions appear to work fine.

When asking a questions, when you say “doesnt work correctly” it would be helpful to know “how” it doesn't work correctly - what are you expecting and what is it doing.

From the image, it can be seen that the variable Bard currently has a value of “1”, so it seems it is at least working to some degree. In the action at the bottom of the Set Variable to Text action, you can see this:


which means the current value of the variable is “1” and the action would set it to “2”.