Author Topic: Use a command to change a command?  (Read 2445 times)

jonsky7

  • Newbie
  • *
  • Posts: 14
Use a command to change a command?
« on: February 03, 2021, 06:28:44 AM »
Hi

Not sure if this is possible, but is there a way to change a "spoken command" with another "spoken command"?

Basically I have a spoken command
Code: [Select]
"when I say: Logistics menu"
Execute command - Open main menu
press F10
Press F3
I am now in the logistics menu.

I'd like to be able choose whether this command presses F3, or change and set it to F4/F5 on the fly.

I use voiceattack for DCS, and play on a server with CTLD logistics (troop transport etc).
The logistics part is accessed via an in-game menu system using F keys. I have set up my profile and it works.
However the F key to access the logistics part of the menu can change from F3/F4/F5/F6 each time I spawn a new aircraft, which is annoying.

So currently, I open the profile editor, and manually change the F3 to whatever F key is required.
Other commands also rely on this command to function, eg
Code: [Select]
"When I say - Troops menu"
execute command Logistics menu
Press F1


I'd love to be able to say "set logistics F4" and that would change the "Logistics menu" command to press F4 instead of F3.

Thanks


jonsky7

  • Newbie
  • *
  • Posts: 14
Re: Use a command to change a command?
« Reply #1 on: February 03, 2021, 06:44:01 AM »
Think I might go with profile switching. Something I think I can manage  :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Use a command to change a command?
« Reply #2 on: February 03, 2021, 01:53:04 PM »
Having the same commands in various different profiles would make maintenance impractical, as you'd need to replicate any change or addition you make in all of them.

You could use a variable keypress for this, which presses a key according to the value of a text variable, so you can change the value of that variable depending on where in the menu your aircraft is listed.

E.G.
Set logistics F[1..12]
Code: [Select]
Set text [logisticsMenuSlot] to '[F{TXTNUM:"{CMD}"}]'

Code: [Select]
"when I say: Logistics menu"
Execute command - Open main menu
press F10
Press variable key(s) [logisticsMenuSlot] and hold for 0,06 seconds and release

Note that this does assume you'll remember to set the slot before attempting to use the command(s) that rely on it, otherwise the variable keypress can't press anything as the variable will not have a value yet


As an aside, you can right-click the action list, choose "Copy All as Text" from the context menu, then paste here into a code block, to list the actual contents of your commands.

jonsky7

  • Newbie
  • *
  • Posts: 14
Re: Use a command to change a command?
« Reply #3 on: February 12, 2021, 09:56:24 PM »
Having the same commands in various different profiles would make maintenance impractical, as you'd need to replicate any change or addition you make in all of them.

It was rather impractical yes, my brain was fried   ::)

But that was exactly what I was looking so thank you very much.  8)




Sprool

  • Newbie
  • *
  • Posts: 8
Re: Use a command to change a command?
« Reply #4 on: March 09, 2022, 03:10:14 PM »
This is exactly what I am stuck with in DCS CTLD menu, which seems to move around depending on mission, server, airframe, thus spoiling my nice linked command chains.
Example - Drop Orange Smoke marker would need \ (comms), F10 (other), F?(ctld), F5 (smoke marker), F3 (orange smoke).
I program it so ctld menu is on F5 but some servers have ctld option as f3 or f4 or f7.
If I can just set the ctld f-number at the start it would all work ok.
Im not experienced enough with this script though to actually write the code. Can anyone guide me?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Use a command to change a command?
« Reply #5 on: March 09, 2022, 03:22:16 PM »
Which part are you having trouble with, specifically?

The example shown is, as you mention, pretty much exactly what you'd need.

For the features involved, you can press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer, which contains information on VoiceAttack's features, and have a look at the following (sub)sections:
  • Dynamic command sections
  • 'Set a Text Value'
  • Text (and Text-To-Speech) Tokens
  • Quick Input, Variable Keypress and Hotkey Key Indicators
  • 6 – Variable Keypress (Advanced)

This topic may also be of use, in addition to the official documentation:
Variables and tokens summed up

Sprool

  • Newbie
  • *
  • Posts: 8
Re: Use a command to change a command?
« Reply #6 on: March 09, 2022, 03:41:16 PM »
Thanks, I'm on the shallow beginner slopes of the learning curve, I'll just have to get stuck in and try programming some more complex commands. All Ive done so far in VA is simple basic chains of keypresses.

Sprool

  • Newbie
  • *
  • Posts: 8
Re: Use a command to change a command?
« Reply #7 on: March 09, 2022, 03:55:10 PM »
not sure where or how to add this command to a profile :(
Code: [Select]

Set text [logisticsMenuSlot] to '[F{TXTNUM:"{CMD}"}]'


Code: [Select]

"when I say: Logistics menu"
Execute command - Open main menu
press F10
Press variable key(s) [logisticsMenuSlot] and hold for 0,06 seconds and release

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Use a command to change a command?
« Reply #8 on: March 09, 2022, 04:14:49 PM »
The "Code:" blocks are examples of what the action list of your command would look like when you have added the appropriate actions to it.
In this case the second block in my post is not verbatim, as it was partially adapted from the initial post by the topic starter.


The first block consists of a "Set a Text Value" action, which uses tokens to remove any non-numeric characters from the spoken command phrase, and sets the variable to that literal text value (which tokens are always rendered as).


The verbatim version of the second block could look like this:
Code: [Select]
Execute command, 'Logistics menu' (and wait until it completes)
Press F10 key and hold for 0.01 seconds and release
Press variable key(s) [logisticsMenuSlot] and hold for 0.01 seconds and release

It consists of three actions:

The "Execute Another Command" action does exactly that: it executes another command. In this case one that presumably contains the appropriate sequence of input to open a "Logistics menu"

The next action is a keypress action set to the default "Press And Release Key(s)" option, with the "Variable Keypress (Advanced)" option unchecked, which presses the F10 key

Lastly is another keypress action, also set to the default "Press And Release Key(s)" option, with the "Variable Keypress (Advanced)" option checked, and the name of the text variable that will be set by the first command in the field for that option.


The first two actions are supplementary. The last keypress action would be how you want to modify the action(s) that currently press F5, F3, F4, or F7 in your existing commands to open this "CTLD menu", in order to be able to use the first command to set which of those keys should be pressed.


The keypress action is added just like any other keypress action, by using the "Key Press" button on the "Add a Command"/"Edit a Command" window (though you could instead modify the existing keypress action, as mentioned).

The "Set a Text Value" action can be found in the "Advanced" section of the context menu for the "Other >" button, also on that window.

Sprool

  • Newbie
  • *
  • Posts: 8
Re: Use a command to change a command?
« Reply #9 on: March 09, 2022, 04:44:37 PM »
So first I set up a command to set CTLD to F5 (for example)
If I call this ctld, then it gets assigned a value of 5.
Then if I have a command 'drop smoke' I need to press keys \, F10, [ctld], F5, F3 = orange smoke, and I use the variable key [ctld] in the command chain to do this?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Use a command to change a command?
« Reply #10 on: March 09, 2022, 04:58:04 PM »
If you set a text variable to a literal value of "5", that will not press F5, no.

Other than that, if your command's action list would normally look like
Code: [Select]
Press \ key and hold for 0.01 seconds and release
Press F10 key and hold for 0.01 seconds and release
Press F5 key and hold for 0.01 seconds and release
Press F5 key and hold for 0.01 seconds and release
Press F3 key and hold for 0.01 seconds and release
and you want the first F5 press to use a variable keypress instead, you'd modify that to
Code: [Select]
Press \ key and hold for 0.01 seconds and release
Press F10 key and hold for 0.01 seconds and release
Press variable key(s) [CTLD] and hold for 0.01 seconds and release
Press F5 key and hold for 0.01 seconds and release
Press F3 key and hold for 0.01 seconds and release
assuming the variable you have set is named "CTLD".

Sprool

  • Newbie
  • *
  • Posts: 8
Re: Use a command to change a command?
« Reply #11 on: March 09, 2022, 05:09:26 PM »
Thabks for your patience! I have it basically working - though it seems quite unstable. In the test it drops smoke 30% of the time, the rest of the time it ends up displaying the F10 map with no smoke dropped. It feels quite buggy. Ive seen threads about having to reset the comms menu before executing commands- would that help?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Use a command to change a command?
« Reply #12 on: March 09, 2022, 05:20:52 PM »
If you are attempting to operate a menu system in your target application that does not open in the same state every time (E.G. it "remembers" the position you were last using), you will need to find a method to reset that state/position, yes.

You are instructing VoiceAttack to press a set sequence of keys, just like you would on your physical keyboard, so if pressing the exact same sequence of keys on your physical keyboard manually would not always result in the same outcome, logically, having VoiceAttack do it for you will not either.


Aside from that, you may also need to add a short pause between the different actions in your command. VoiceAttack can send keypresses much faster than you physically could, so the target application may miss or ignore keypresses if they are sent without any delay between each keypress.


If you are looking for a pre-built solution to operating communications menus in DCS, the third-party VAICOM (PRO) addon may be relevant (though this is not intended as a personal endorsement).