Author Topic: My first ever question - repeating a command with a simple prompt  (Read 4641 times)

filthymanc

  • Guest
Hi all,
Love VA.  It's the future.
I like to think that I have a good grasp of the basics of VA and have been using it for many months.

I've now got to the stage where I want to start getting smart with commands, but it looks quite daunting.

So, if anyone can help me out, I'd like to figure out how to do the following.....

I have created a command that presses the spacebar when I say "Press the spacebar".

If I want to press the spacebar again, I could repeat the command "Press the spacebar".

But I don't know how many times I want to press it yet, so I don't want to have to keep repeating the words over and over.  Instead I want to start by saying "Press the spacebar", and if I want to do it again, I want to say "Again", and maybe "Again", until I'm happy. These "Again" commands would follow in reasonably quick succession, not with long pauses in between.

The next time, I know that I want to press the spacebar 7 times.  Rather than repeat "Press the spacebar" 7 times or say "Again" 6 times, I'd prefer to say "Press the spacebar seven times".

Hope this is clear. Grateful for any help.
Cheers.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4786
  • RTFM
Re: My first ever question - repeating a command with a simple prompt
« Reply #1 on: October 08, 2017, 07:33:11 PM »
Having an "again" command that repeats the preceding command isn't difficult to set up in itself(you could add it as an alias for your "Press the spacebar" command, if that's the only one you intend to repeat), however the speech recognition engine has to wait for speech to stop so it can be sure the sentence is complete before it attempts to process it; This means you'll always have to allow for a delay between different commands.


For a command that will execute a variable number of times, you can use the For loop implemented in VoiceAttack v1.6.5:
Press the spacebar [2..10] times
Code: [Select]
Start Loop : Repeat [{TXTNUM:"{CMD}"}] Times
End Loop
The "{TXTNUM:}" token will extract the number from the command phrase you have spoken(returned by the "{CMD}" token), and pass that on to the For loop, which will execute whatever is between the "Start Loop" and "End Loop" actions and repeat the amount of times you've set.