Author Topic: Hi Guys... VA Newbie Loop keypress question  (Read 1178 times)

tozstyle

  • Newbie
  • *
  • Posts: 3
Hi Guys... VA Newbie Loop keypress question
« on: December 07, 2021, 04:09:41 AM »
Hi, I'm just getting started with VA a would like to know how i can set a command to keep pressing a key ( with the ability to change the timing in between the key press ) until i stop the command. would be great to bind this to not only a voice command but also a start and stop keypress. please help  :)

Castleberg

  • Newbie
  • *
  • Posts: 37
Re: Hi Guys... VA Newbie Loop keypress question
« Reply #1 on: December 07, 2021, 04:22:33 AM »
While no doubt Pfeil will respond with a far more sophisticated response....

You could accomplish this in any number of ways.

The most simply way is probably Just to do the following:

Create a command.
under the command name you will see a "when I press" radio box. Check that and you can select the trigger key
Under the command, create a while loop (Other -> Advanced -> Add a loop start -> Single Condition While loop.
Within the following dialoge select Device State on the far right.
Choose your device and button.
Select while pressed.

Within the loop created, add either a "quick input" or "keypress"  command. You can set the timing "between keystrokes" in the respective dialogues

Now when you press the command trigger, your command which launch, which so long as you continue pressing the key, it will loop with the timings specified.

Code: [Select]
Start Loop While :  Keyboard Key 'A' Is Pressed
    Press T key and hold for 0.1 seconds and release
End Loop

The above command, when "A" is assigned as the launch trigger will effectively make your "A" key function as your "T" key. for example, and if "A" is held, it will repeat at the desired rate.


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: Hi Guys... VA Newbie Loop keypress question
« Reply #2 on: December 07, 2021, 04:48:22 AM »
Assuming that by "keep pressing a key" you mean press and release it repeatedly, that can be done fairly simply using two commands:

When I say: Start repeated keypress
Code: [Select]
Press A key and hold for 0,02 seconds and release
Pause 0,1 seconds
Where the "Repeating" option for the command is set to "Repeat continuously until stopped"

When I say: Stop repeated keypress
Code: [Select]
Kill command, 'Start repeated keypress'



If you are indeed looking to have a key pressed and released repeatedly when you hold down another key, no explicit loop is required, as you can enable the "Repeat command while keys are held down" option when setting the "When I press keys:" shortcut.
« Last Edit: December 07, 2021, 06:09:38 AM by Pfeil »

tozstyle

  • Newbie
  • *
  • Posts: 3
Re: Hi Guys... VA Newbie Loop keypress question
« Reply #3 on: December 07, 2021, 05:22:19 AM »
thanks, will give it a try

tozstyle

  • Newbie
  • *
  • Posts: 3
Re: Hi Guys... VA Newbie Loop keypress question
« Reply #4 on: December 07, 2021, 05:59:52 AM »
perfect thanks, when you see it .... you see it lol