Author Topic: Extract dynamic variable from spokend command?  (Read 4304 times)

Jonn

  • Guest
Extract dynamic variable from spokend command?
« on: August 18, 2017, 12:01:47 PM »
Hello everyone :)

I'm a handicapped person that have been using VA for a few years now. My hands are not working, but with eye-tracking together with VA I'm able to use the computer. My VA macros are pretty basic and I want to improve them.

I have a few commands with number input, such as "Pixel left 10" (move cursor) , " Axis left 5" (direction keys) and "Zoom in 3" (mouse scroll wheel) .

I made seperate commands for the various numbers and various directions and always found it tedious. I now understand that you can use variables in the spoken command, but I still don't understand how I can read those variables from the spoken command?

If I made a command like "Pixel [left;right;up;down] [1..10000]" how can I read those variables so I can use them in a loop- or if-block?

Any help is much appreciated :)

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Re: Extract dynamic variable from spokend command?
« Reply #1 on: August 18, 2017, 12:25:41 PM »
Hi, Jonn.

You'll want to look in the help doc for, 'Dynamic command sections' and the corresponding token, '{CMDSEGMENT:segment}'

To get the direction, you'll want to check the value of {CMDSEGMENT:1}.  To get the numeric value, you'll use {CMDSEGMENT:2}.  {CMDSEGMENT:0} will always be, 'Pixel'.

Sorry for the short answer... I'm not at my computer ;)   I'm sure Pfeil will have a very detailed and better answer, but I was hoping to at least get you off in a direction.

Just an fyi on this, you're looking at an excess of 40,000 commands being added in the background.  I think it will load pretty quick nowadays, but there will still be some lag I'm sure.

Jonn

  • Guest
Re: Extract dynamic variable from spokend command?
« Reply #2 on: August 18, 2017, 05:51:22 PM »
Thanks for your reply :)

I read (fast) through the manual, I missed it completely the first time. I'm rewriting a bunch of commands now :) 

I got a warning about many commands, so I reduced the number a lot.  I used [1..10;1..10,10;1..10,100] instead.

I have on problem
My command: "Axis [left;right;up;down] [1..10;]"

So I can say "Axis right 1" and a loop moves the direction right key 1 time.
But when I try to say "Axis left" it doesn't work even though I've created an If block that sets the loop counter to 1 when the number wasn't stated ({CMDSEGMENT:2} Has not been set).

Here is my code, help is greatly appreciated :)

axis [left;right;up;down] [1..10;1..10,10;]
Code: [Select]
Set Text [direction] to '{CMDSEGMENT:1}'
Begin Text Compare : [{CMDSEGMENT:2}] Has Not Been Set
    Set integer [number] value to 1
Else
    Set integer [number] value to the converted value of {CMDSEGMENT:2}
End Condition
Begin Text Compare : [direction] Equals 'left'
    Start Loop : Repeat [number] Times
        Press Left key and hold for 0,1 seconds and release
        Pause 0,05 seconds
    End Loop
Else If Text Compare : [direction] Equals 'right'
    Start Loop : Repeat [number] Times
        Press Right key and hold for 0,1 seconds and release
        Pause 0,05 seconds
    End Loop
Else If Text Compare : [direction] Equals 'up'
    Start Loop : Repeat [number] Times
        Press Up key and hold for 0,1 seconds and release
        Pause 0,05 seconds
    End Loop
Else If Text Compare : [direction] Equals 'down'
    Start Loop : Repeat [number] Times
        Press Down key and hold for 0,1 seconds and release
        Pause 0,05 seconds
    End Loop
End Condition

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: Extract dynamic variable from spokend command?
« Reply #3 on: August 18, 2017, 10:28:20 PM »
To keep segment numbers predictable, unused/not spoken ones will return ""(blank) instead of "Not Set", so in your case "{CMDSEGMENT:2}" will never be "Not Set".
"{CMDSEGMENT:3} would be, because the command has only 3 segments, which being zero-indexed means the highest index would be 2.

Use
Code: [Select]
Begin Text Compare : [{CMDSEGMENT:2}] Equals ''instead.

Jonn

  • Guest
Re: Extract dynamic variable from spokend command?
« Reply #4 on: August 19, 2017, 06:22:02 AM »
Nice!

Thank you so much, that fixed it :)