Author Topic: Mixing two sets of possible phrases into one output  (Read 804 times)

duglet

  • Newbie
  • *
  • Posts: 3
Mixing two sets of possible phrases into one output
« on: August 04, 2019, 08:28:24 PM »
Hi there. I am a beginner with VA and have done a fair bit of bloated scripting which has served me fine until this point. Now I am stuck. Here's what I want to do.

Part 1: Say a range of 1-40, each number is used to decide where to move mouse co-ordinates and click. This is easy to do as an individual command I know. I can just write it once, duplicate it 40 times and adjust the mouse co-ordinate.

Part 2: Say "huge/big/medium/small/tiny" and do an action

The end result would be VA understanding "22 huge" it will click a co-ord and press 1. Then I say "35 medium" for another co-ord and 3. "13 tiny" for another co-ord and SHIFT+6. Any mix of the above.

It is important that VA takes this as a single command spoken fluently and I want to get it to respond as quickly as possible. I have a feeling it could be done easy enough with two commands but it would be too slow while VA decides on each spoken phrase and each command.

It would be very impractical to write an individual option for each of these as it would conservatively work out to hundreds of commands and would be very hard to manage. Instead it would be far easier to write the mouse co-ord and click commands for 1-40, and mix them with the second step for the following key press.

I have been watching Youtube videos about doing more advanced things with prefix:suffix arrangements, some dynamic options, but I don't need to return a complicated command or even rearraange how it is given, I just need to cover a very wide spread of similar commands. It will always move mouse to co-ord and click decided by 1-40, then the follow-up key press decide by a few different phrases.

Thank you in advance!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: Mixing two sets of possible phrases into one output
« Reply #1 on: August 04, 2019, 08:39:16 PM »
You can use dynamic command sections for the phrase itself, and conditions to select the coordinates and the keypress.

E.G.
[1..40] [huge;big;medium;small;tiny]
Code: [Select]
Begin Text Compare : [{CMD}] Contains '1'
    Set Text [~X] to '100'
    Set Text [~Y] to '100'
Else If Text Compare : [{CMD}] Contains '2'
    Set Text [~X] to '200'
    Set Text [~Y] to '200'
End Condition
Move mouse cursor to screen coordinates by text/token X:{TXT:~X}, Y:{TXT:~Y}
Click left mouse button
Begin Text Compare : [{CMD}] Contains 'huge'
    Press 1 key and hold for 0,01 seconds and release
Else If Text Compare : [{CMD}] Contains 'big'
    Press 2 key and hold for 0,01 seconds and release
End Condition

duglet

  • Newbie
  • *
  • Posts: 3
Re: Mixing two sets of possible phrases into one output
« Reply #2 on: August 04, 2019, 09:13:37 PM »
Thank you for the quick reply and elegant solution. I am very impressed with VA and it is changing the way I do many things. I successfully replicated your example and it works.

Begin Text Compare : [{CMD}] Contains '1'
    Set Text [~Y] to [100]
    Set Text [~X] to [100]
Else If Text Compare : [{CMD}] Contains '2'
    Set Text [~Y] to [200]
    Set Text [~X] to [200]
End Condition
Move mouse cursor to screen coordinates by text/token X:{TXT:~X}, Y:{TXT:~Y}
Pause 0.05 seconds
Click left mouse button
Pause 0.05 seconds
Begin Text Compare : [{CMD}] Contains 'huge'
    Pause 0.05 seconds
    Press 1 key and hold for 0.1 seconds and release
    Pause 0.05 seconds
End Condition
Begin Text Compare : [{CMD}] Contains 'big'
    Pause 0.05 seconds
    Press 2 key and hold for 0.1 seconds and release
    Pause 0.05 seconds
End Condition

duglet

  • Newbie
  • *
  • Posts: 3
Re: Mixing two sets of possible phrases into one output
« Reply #3 on: August 05, 2019, 01:39:45 AM »
Okay turns out I spoke too soon. I'm getting an error about the mouse position, saying the co-ordinates couldn't be resolved. I can enter it manually without tokens and it works that way. Is there a particular reason that I should convert the co-ordinates to a token?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: Mixing two sets of possible phrases into one output
« Reply #4 on: August 05, 2019, 08:04:33 AM »
Compare my example:
Code: [Select]
Set Text [~X] to '100'to yours:
Code: [Select]
Set Text [~Y] to [100]
You need to use the "Text" field of the "Set a Text Value" action.


That said, you could indeed just use a mouse move within each conditional branch directly.