Author Topic: How do I create a command, that switches between "push-to-listen" and "always-li  (Read 8132 times)

SaveMySoul

  • Guest
How do I create a command, that switches between "push-to-listen" and "always-listening" ?

Is there any way to code this besides creating two profiles (one for each mode) and making the command switch between those profiles?

Help would be very much appreciated.
Thank you in advance!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
You can't switch the profile hotkey option, but if you turn that off, you can use a command to trigger push to talk:
Push to listen;Always listen
(When I press keys : Left Alt)
Code: [Select]
Begin Text Compare : [{CMDACTION}] Equals 'Spoken'
    Begin Text Compare : [{CMD}] Contains 'Push'
        Set Boolean [PTT] to True
    Else
        Set Boolean [PTT] to False
    End Condition
Else
    Start VoiceAttack listening
    Start Loop While : [{STATE_KEYSTATE:LALT}] Equals '1'
    End Loop
End Condition
Begin Text Compare : [{EXP: {BOOL:PTT} = True And {STATE_KEYSTATE:LALT} = 0}] Equals '1'
    Stop VoiceAttack listening
End Condition
Make sure the "Allow other commands to be executed while this one is running" option is checked.

I used "Left Alt" in the example because it's a popular choice for push-to-talk, but you can use another key by changing the "When I press keys" option and the "{STATE_KEYSTATE:}" tokens.
A list of special(non single-character) keys is in VoiceAttack's documentation under "Key State Token Parameter Values".

SaveMySoul

  • Guest
Thank you for your quick response!

As you suggested, I turned off Push-to-listen in VA's settings and in the profiles settings -> its all disabled and now VA listens all the time. Also I changed LALT to F12, since I use that hotkey for push to listen. Hence the code looks as follows (I also enabled other commands to run while this one is on):

Code: [Select]
Begin Text Compare : [{CMDACTION}] Equals 'Spoken'
    Begin Text Compare : [{CMD}] Contains 'Push'
        Set Boolean [PTT] to True
    Else
        Set Boolean [PTT] to False
    End Condition
Else
    Start VoiceAttack listening
    Start Loop While : [{STATE_KEYSTATE:F12}] Equals '1'
    End Loop
End Condition
Begin Text Compare : [{EXP: {BOOL:PTT} = True And {STATE_KEYSTATE:F12} = 0}] Equals '1'
    Stop VoiceAttack listening
End Condition

Sadly when I trigger this command, it gets recognized and triggers, but I doesn't change the recognition. It still listens 24/7 and doesn't await me pushing F12 to listen. What did I do wrong?

The reason I am looking for such a command, is because I would like to have two modes within one profile.
Mode1: I can speak freely with VA and dont have to bother with pushing a button so that it listens and
Mode2: for when I am simultaneously in teamspeak and need to push a key for VA to listen (that key also temporarily mutes me in TS, hence my friends dont have to listen to me giving VA orders).

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
What's the name of your command?

If you're using something other than Push to listen;Always listen, that doesn't include the word "Push", you need to change the second text compare to look for something else to determine what you want the listening state to be.

SaveMySoul

  • Guest
Dear Sir, you are an absolute genius!

I've finally gotten around to take an in depth look at it and you were right: I named the command incorrectly.
Now it works perfectly! Thank you very much! :)

Maybe you could just give me one last advice and I'll be out of your hair.
How can I execute the command you were so kind to write for me within another command? Either triggering "always listen" or "push to listen".

I tried the code below, but even though it's told to execute "always listen", it triggers "push to listen".

Code: [Select]
Execute command, 'Always listen' (by name) (and wait until it completes)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
How can I execute the command you were so kind to write for me within another command? Either triggering "always listen" or "push to listen".

I tried the code below, but even though it's told to execute "always listen", it triggers "push to listen".
Executing a command by name currently doesn't pass the exact phrase to the "{CMD}" token, rather it passes the complete command name, E.G. "Push to listen;Always listen", so the command always sees "Push".

I've put it a feature request to see if it's feasible to change this in future. EDIT: Feature will be in the next beta. Thanks Gary!

However, for now, you should be able to switch between the two modes using the following:
Code: [Select]
Set Boolean [PTT] to FalseAssuming you're holding the push-to-talk key, this will make VoiceAttack listen continuously when it's released(variables are global, so the command you invoke when pressing the key will see the modified value when you release it)

Code: [Select]
Set Boolean [PTT] to True
Stop VoiceAttack listening
As presumably you're not holding down the push-to-talk key when switching to that mode, you need to explicitly turn off listening.
« Last Edit: January 20, 2017, 12:10:08 AM by Pfeil »

SaveMySoul

  • Guest
Fascinating, how well it works. I cannot thank you enough!
And as I have seen, you even managed to get that {CMD}-thingy to be patched in the future, so that it will even work with this code:

Code: [Select]
Execute command, 'Always listen' (by name) (and wait until it completes)
Thank you!! :)

toby23

  • Guest
Hello,
Reviving this old post in the hope that someone can help me out.

I would like my in-game Push to talk button to mute Voice Attack, so that I can speak to friends in-game without VA listening.

I cannot figure out what I need to do in VA.
Sorry, I am not a programmer and don't understand the section above well enough to use it.

Appreciate any help..


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
I would like my in-game Push to talk button to mute Voice Attack, so that I can speak to friends in-game without VA listening.

This is built into VoiceAttack itself:

Click , click the "Hotkeys" tab, click "..." underneath "Recognition Global Hotkey", check "Enable keyboard global hotkey", press the key(s) you use for ingame push-to-talk, under "When the hotkey is pressed" click the "VoiceAttack stops listening while keys are down" radio button, click "OK", click "OK" to save the option.

toby23

  • Guest
I have set this up in VA and in Elite and it works when VA has the focus but as soon as I am in game, VA does not recognise the key press any more..

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
It's a global hotkey, so it should work no matter which application has focus. Are you running VoiceAttack as admin?

toby23

  • Guest
Yes, VoiceAttack is running as Admin.
Does each game have to run in Admin mode too, if it uses VoiceAttack, for my plan to work?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
No, as long as VoiceAttack is running as admin it should be able to access anything either also running as admin or lower.

An application running as admin can access another that's either running as a normal user, or as admin, but an application that's running as a normal user can't access one running as admin.


Permissions is only one reason why keypresses don't get through, I know some games prevent any applications started before them from receiving keypresses(seemingly accidentally), though I've not heard of Elite doing so.

toby23

  • Guest
Is it correct that this should work with a joystick button instead of a keyboard button press?
When I test it directly in VoiceAttack, it works fine but as soon as I switch to Elite, it stops recognising the button press, which works fine to allow voice chat in Elite.
Is there another way around this? Maybe creating a custom 'stop listening' command in VoiceAttack when this button is pressed? Can you help me write this command as I don't know where to start?

Thanks.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
If the global hotkey isn't recognized, a command shouldn't be recognized either, as they both use the same system.

You can try creating a command triggered by a joystick button(using the "When I press button" option in the "Add/Edit a Command" window) to verify this.