Author Topic: {STATE_KEYSTATE: key}  (Read 4660 times)

JDsplice

  • Newbie
  • *
  • Posts: 20
{STATE_KEYSTATE: key}
« on: December 14, 2016, 04:47:25 PM »
I am having trouble understanding from the documentation on how to properly use the {STATE_KEYSTATE: key} token.

I want to VA to jump the second I press the [ENTER] key in a loop check, but do nothing until I do.  Here is my thought process...

Loop Start
   {STATE_KEYSTATE: ENTER}
   If {STATE_KEYSTATE: ENTER}=1 then jump to End
Loop End
End

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: {STATE_KEYSTATE: key}
« Reply #1 on: December 14, 2016, 04:50:55 PM »
Code: [Select]
Start Loop While : [{STATE_KEYSTATE:ENTER}] Equals '0'
End Loop
You don't need a jump. When the loop ends, whatever is placed below it will run.

JDsplice

  • Newbie
  • *
  • Posts: 20
Re: {STATE_KEYSTATE: key}
« Reply #2 on: December 14, 2016, 05:35:51 PM »
Awesome, I can't thank you enough.  The next part may seem strange, but it's a braille thing.

Is there a "simple" way of having VA log my keystrokes into a variable so I can manipulate them?  Perferably one variable per keystoke to make things easier cuz I have to move the "g" in 345g to the beginning of a sequence and convert the numerics to alphas.  [1=a, 2=b, ..., 0=j]

So if I typed or spoke 345g, VA would store it as (c)(d)(e)(g).

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: {STATE_KEYSTATE: key}
« Reply #3 on: December 14, 2016, 06:09:36 PM »
Is there a "simple" way of having VA log my keystrokes into a variable so I can manipulate them?
If it needs to accept any key on a standard 105 key keyboard, no. I made a request for a catch-all system to facilitate this, but that's not implemented.

If you need a limited amount of keys, it's doable, if cumbersome, as you'll have to check the tokens for every single key you want to use in a loop, and make sure keys are lifted before adding them again so you don't get multiple characters for every keypress.

Perferably one variable per keystoke to make things easier cuz I have to move the "g" in 345g to the beginning of a sequence and convert the numerics to alphas.  [1=a, 2=b, ..., 0=j]
If the letter is always suffixed, you could use "{TXTALPHA:}" and "{TXTNUM:}" to change the order.

To convert the sequence to letters you can use a lookup table, which is basically a long list of conditions(in VoiceAttack at least), and loop through the string:
Code: [Select]
Set Text [Input] to '345g'
Set small int (condition) [StringLength] value to the converted value of {EXP:{TXTLEN:Input}-1}
Set small int (condition) [LoopCount] value to 0
Set Text [Output] to ''
Start Loop While : [LoopCount] Does Not Equal [StringLength]
    Set Text [Char] to '{TXTSUBSTR:Input:{SMALL:LoopCount}:1}'
    Begin Text Compare : [Char] Equals '1'
        Set Text [Char] to 'a'
    Else If Text Compare : [Char] Equals '2'
        Set Text [Char] to 'b'
    Else If Text Compare : [Char] Equals '3'
        Set Text [Char] to 'c'
    Else If Text Compare : [Char] Equals '4'
        Set Text [Char] to 'd'
    Else If Text Compare : [Char] Equals '5'
        Set Text [Char] to 'e'
    Else If Text Compare : [Char] Equals '6'
        Set Text [Char] to 'f'
    Else If Text Compare : [Char] Equals '7'
        Set Text [Char] to 'g'
    Else If Text Compare : [Char] Equals '8'
        Set Text [Char] to 'h'
    Else If Text Compare : [Char] Equals '9'
        Set Text [Char] to 'i'
    Else If Text Compare : [Char] Equals '0'
        Set Text [Char] to 'j'
    End Condition
    Set Text [Output] to '{TXTCONCAT:Output:Char}'
    Set small int (condition) [LoopCount] value as incremented by 1
End Loop
Write '[Purple] {TXTALPHA:Input}{TXT:Output}' to log

JDsplice

  • Newbie
  • *
  • Posts: 20
Re: {STATE_KEYSTATE: key}
« Reply #4 on: December 14, 2016, 06:36:00 PM »
Thanks, that gives me some food for thought.