# Lemur: creating a toggle effect with two commands on 1 button



## tarantulis (Jan 17, 2019)

Hey guys, I'm trying to create a toggle effect in Lemur for two commands that would traditionally require separate buttons (enable + disable). This is what I'd like to do:

1.) First press: send CC(X) to trigger "enable" macro in Cubase
2.) Second press: send CC(Y) to trigger "disable" macro in Cubase

Since it's being sent as a command, I can't enable "toggle" in the Generic Remote Editor. So my workaround idea would be to have two separate macros, one for enable and one for disable, triggered separately on the same button.

Is this possible?


----------



## pmcrockett (Jan 18, 2019)

Something like this?

Add a CustomButton object. In the Behavior tab of the Objects pane, make sure mode is set to Switch. Add a script to the object (name doesn't matter), and at the top of the script pane set the script's execution to On Expression x (any). Then paste the following code:

```
if (x == 0)
{
        ctlout(0, 20, 0, 1);
}
else
{
        ctlout(0, 20, 127, 1);
}
```

This gives you a toggle button that will send unique CC messages for off (x is 0) and on (x is 1). You can look up the ctlout command on page 131 of the manual, but the way this example is set up, it sends a value of 64 (off) or 127 (on) on CC 20, channel 1, to Lemur MIDI target 0.


----------



## tarantulis (Jan 19, 2019)

This is exactly what I was looking for. Thanks a ton!


----------

