Author Topic: Repeated command (keypress) but only with one text-to-speech notification  (Read 4771 times)

pavsko

  • Guest
Hi,
please help me: I need to press some key 5 times but I want only once to hear the text-to-speech voice confirmation. How can be this done?
Thanks for tips.

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
If I understand you correctly you're looking to press a key 5 times and only on the 5th press you want to hear a TTS response. Here is one way of accomplishing that:

Code: [Select]
Begin Boolean Compare : [pressFlag] Equals False (evaluate 'Not Set' as false)
    Set Boolean [pressFlag] to True
End Condition
Set integer [pressCount] to [pressCount] plus 1 (evaluate Not Set as zero)
Write '[Blue] Press Count = {INT:pressCount}' to log
Begin Integer Compare : [pressCount] Is Less Than 5
    Exit Command
Else
    Set integer [pressCount] value to [Not Set]
    Say, '5 key presses confirmed'  (and wait until it completes)
End Condition

So basically each key press while pressCount is less than 5 will increment pressCount, output its value (shown only for debugging convenience), and immediately exit the command. But keep in mind that pressCount is a globally-scoped variable (you could also use a profile-scoped variable and this method would still work, see page 156 of the Help Document for more info about variable scope), and VA "remembers" its value between calls for this function. Once pressCount reaches 5 then pressCount's value gets outputted and cleared, and the TTS confirmation is played. Additional coding can be done in case you want any accidental extra presses discarded.

Does the above example help?

pavsko

  • Guest
Thanks very much for answer.
I am new to VA and though I think I understand the code you posted I have not discovered where to paste it inside an "Edit a command" window... i.e. is there a way how insert the whole macro you posted or I need to write it step by step via Other -> Advanced items?
« Last Edit: July 13, 2017, 12:50:33 PM by pavsko »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
The "5 Press 1 Speak.vap" file attached to that post can be imported into VoiceAttack.

The "code" block is what you're see in the action list after importing, though it should also provide enough information to recreate the command manually.

pavsko

  • Guest
Yes, it works  :) Thanks again!