Author Topic: Stop a continuous command with the same words  (Read 802 times)

CJ_squared

  • Newbie
  • *
  • Posts: 1
Stop a continuous command with the same words
« on: January 25, 2020, 02:35:36 PM »
I made a command that auto clicks my mouse indefinitely and I would like to use the same command to turn it off. I am very new to VoiceAttack

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Stop a continuous command with the same words
« Reply #1 on: January 25, 2020, 09:34:46 PM »
That's certainly possible:
Code: [Select]
Begin Boolean Compare : [>{CMDWHENISAY}running] Equals True
    Set Boolean [>{CMDWHENISAY}running] to [Not Set]
    Write [Blue] '{CMDWHENISAY} loop stopped' to log
End Condition - Exit when condition met
Set Boolean [>{CMDWHENISAY}running] to True
Write [Blue] '{CMDWHENISAY} loop started' to log
Start Loop While : [>{CMDWHENISAY}running] Equals True
    Click left mouse button
    Pause 0,1 seconds
End Loop
The "{CMDWHENISAY}" token will be replaced by the contents of the "When I say" field of that command, which will be unique to that specific command. Because of this, you could duplicate this command to set up a different self-toggling command, and the only thing that would need to be modified is the actions inside the while loop that you want to have executed.

Make sure to check the "Evaluate 'Not Set' as false" in the "Begin a Conditional (If Statement) Block" and "Loop Start" actions.

As this uses loop actions, rather than repeating the entire command, also make sure the "Repeating" option for the command is set to "Execute only once".