Need help with Buttons and global variables

I am trying to create a Menu Button with three buttons. What I want to achieve is:

  • When I select the first button: launch specific command (app) and set global variable to indicate this.
  • Same for the second button: launch specific command set the same global variable.
  • Third button is disabled until the global variable is set. If set: launch specific command, kill global variable.

Can someone help me how to achieve this? I tried several examples from help (@toggle command modifier), but I am missing something...

OK, I found a solution. Actually I don't need the third menu item. I have two buttons with the following code:

@disableif:$glob:WS2
@toggle:if $glob:WS1
@if:$glob:WS1
@set glob:WS1
@runmode:hide
// do something here
@if:else
@set glob:WS1=on
@runmode:hide
// do something here

And for the second button:

@disableif:$glob:WS1
@toggle:if $glob:WS2
@if:$glob:WS2
@set glob:WS2
@runmode:hide
// do something here
@if:else
@set glob:WS2=on
@runmode:hide
// do something here