Author Topic: Checking pressing  (Read 27511 times)

0 Members and 1 Guest are viewing this topic.

NooBAsTiK

  • Jr. Member
  • **
  • Posts: 33
  • Karma: 0
    • View Profile
    • SquaD Skulls
Re: Checking pressing
« Reply #15 on: January 27, 2015, 02:10:00 PM »
На словах то конечно просто :) Попробую разобраться про маппинг смотрел видео, вроде ничего сложного, хотя по английский хромает...

Phobophile

  • Jr. Member
  • **
  • Posts: 36
  • Karma: 7
    • View Profile
    • Facebook
Re: Checking pressing
« Reply #16 on: January 27, 2015, 02:41:04 PM »
На словах то конечно просто :) Попробую разобраться про маппинг смотрел видео, вроде ничего сложного, хотя по английский хромает...
Попробуй, если не получится, то могу попробовать сделать примерный скрипт, просто ща под рукой VC нет и времени особо тоже. :)

NooBAsTiK

  • Jr. Member
  • **
  • Posts: 33
  • Karma: 0
    • View Profile
    • SquaD Skulls
Re: Checking pressing
« Reply #17 on: January 28, 2015, 06:56:18 AM »
В выходные попробую, если не будет получаться отпишусь  :)

NooBAsTiK

  • Jr. Member
  • **
  • Posts: 33
  • Karma: 0
    • View Profile
    • SquaD Skulls
Re: Checking pressing
« Reply #18 on: January 31, 2015, 11:45:18 AM »
Не понимаю что я делаю не так:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.3-->
<commandGroup open="True" name="La-5" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="94" name="Запись полета" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{var.rec}&amp;&amp;0</ifParams>
      <then>
        <action>
          <cmdType>DxInput.KeyCombo</cmdType>
          <params>
            <param>{LeftControl}</param>
            <param>{R}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>rec</param>
            <param>1</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись включена</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись уже идет</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{var.rec}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Записать полет,запись полета,включить запись,сохранить запись</phrase>
  </command>
  <command id="107" name="Остановить запись" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{var.rec}&amp;&amp;1</ifParams>
      <then>
        <action>
          <cmdType>DxInput.KeyCombo</cmdType>
          <params>
            <param>{LeftControl}</param>
            <param>{R}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>{var.rec}</param>
            <param>0</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись выключена</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись не была включена</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{var.rec}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Остановить запись,Сохранить запись,Прекратить запись</phrase>
  </command>
</commandGroup>

Вроде должно переключать переменную, а не переключает. Что я делаю не так?

I do not know what I'm doing wrong:

code

Like should switch variable rather than switches. What am I doing wrong?
« Last Edit: January 31, 2015, 11:54:01 AM by NooBAsTiK »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Checking pressing
« Reply #19 on: January 31, 2015, 12:44:06 PM »
When you start VoxCommando the variable has no value.  The way you created your logic block, both commands will fail because the variable is not equal to either 0 or 1.

Also in your second command ("stop recording"), you have entered the wrong parameter in the Results.Setvar action.  You have written {var.rec} but you should have written rec.  The "start recording" command was done correctly.

I changed the logic for you.  The attached commands should work.  I changed:

Code: [Select]
if (rec==0) to
Code: [Select]
if (rec <> 1)and
Code: [Select]
if (rec==1) to
Code: [Select]
if (rec <> 0)
This way they will work when the variable has not been assigned a value yet.

Remember:

1) If you are already recording when VoxCommando first starts then you will have a problem.

2) If you manually press Ctrl-R on your keyboard VoxCommando will not know about it and your variable will have the wrong value, and your voice commands will not work correctly until you press Ctrl-R again.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.6-->
<commandGroup open="True" name="La-5" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="94" name="Запись полета" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)==(B)</ifType>
      <ifParams>{var.rec}&amp;&amp;1</ifParams>
      <then>
        <action>
          <cmdType>DxInput.KeyCombo</cmdType>
          <params>
            <param>{LeftControl}</param>
            <param>{R}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>rec</param>
            <param>1</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись включена</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись уже идет</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{var.rec}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Записать полет,запись полета,включить запись,сохранить запись</phrase>
  </command>
  <command id="107" name="Остановить запись" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)==(B)</ifType>
      <ifParams>{var.rec}&amp;&amp;0</ifParams>
      <then>
        <action>
          <cmdType>DxInput.KeyCombo</cmdType>
          <params>
            <param>{LeftControl}</param>
            <param>{R}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>rec</param>
            <param>0</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись выключена</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись не была включена</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{var.rec}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Остановить запись,Сохранить запись,Прекратить запись</phrase>
  </command>
</commandGroup>

NooBAsTiK

  • Jr. Member
  • **
  • Posts: 33
  • Karma: 0
    • View Profile
    • SquaD Skulls
Re: Checking pressing
« Reply #20 on: January 31, 2015, 12:51:58 PM »
As someone who can link VoxCommando and keyboard?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Checking pressing
« Reply #21 on: January 31, 2015, 01:03:51 PM »
Yes. You can use the "Hook" plugin. :)

Enable the "Hook" plugin. You must log (record) the "Ctrl+R" in the Hook plugin settings and "Add Selected" to the list. Then VoxCommando will generate an event every time you press those buttons, or if you emulate that key combination using "DxInput.Combo".

Add this command to your group:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.6-->
<command id="261" name="keyboard monitor" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <if ifBlockDisabled="False" ifNot="True">
    <ifType>(A)==(B)</ifType>
    <ifParams>{var.rec}&amp;&amp;1</ifParams>
    <then>
      <action>
        <cmdType>Results.SetVar</cmdType>
        <params>
          <param>rec</param>
          <param>1</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>Results.SetVar</cmdType>
        <params>
          <param>rec</param>
          <param>0</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <event>Hook.LControlKey+R</event>
</command>
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

NooBAsTiK

  • Jr. Member
  • **
  • Posts: 33
  • Karma: 0
    • View Profile
    • SquaD Skulls
Re: Checking pressing
« Reply #22 on: January 31, 2015, 01:13:24 PM »
Как я понял на каждую переменную создавать такую строку?

As I understand it to each variable to create a line like this?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Checking pressing
« Reply #23 on: January 31, 2015, 01:16:11 PM »
Yes.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

NooBAsTiK

  • Jr. Member
  • **
  • Posts: 33
  • Karma: 0
    • View Profile
    • SquaD Skulls
Re: Checking pressing
« Reply #24 on: January 31, 2015, 01:25:34 PM »
Этот хук может отследить время удержания кнопки? 1 сек 2 сек?

the "Hook" plugin can keep track of time holding the button? 1 sec 2 sec?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Checking pressing
« Reply #25 on: January 31, 2015, 01:33:57 PM »
As someone who can link VoxCommando and keyboard?

First: I forgot to say that if you are monitoring the variable using the Hook event, then you should not use the Results.SetVar action in the voice commands.

The correct implementation is:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.6-->
<commandGroup open="True" name="La-5 -NEW" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="94" name="Запись полета" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)==(B)</ifType>
      <ifParams>{var.rec}&amp;&amp;1</ifParams>
      <then>
        <action>
          <cmdType>DxInput.KeyCombo</cmdType>
          <params>
            <param>{LeftControl}</param>
            <param>{R}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>rec</param>
            <param>1</param>
          </params>
          <cmdRepeat>0</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись включена</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись уже идет</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{var.rec}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Записать полет,запись полета,включить запись,сохранить запись</phrase>
  </command>
  <command id="261" name="keyboard monitor" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)==(B)</ifType>
      <ifParams>{var.rec}&amp;&amp;1</ifParams>
      <then>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>rec</param>
            <param>1</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>rec</param>
            <param>0</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <event>Hook.LControlKey+R</event>
  </command>
  <command id="107" name="Остановить запись" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)==(B)</ifType>
      <ifParams>{var.rec}&amp;&amp;0</ifParams>
      <then>
        <action>
          <cmdType>DxInput.KeyCombo</cmdType>
          <params>
            <param>{LeftControl}</param>
            <param>{R}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>rec</param>
            <param>0</param>
          </params>
          <cmdRepeat>0</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись выключена</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Запись не была включена</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{var.rec}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Остановить запись,Сохранить запись,Прекратить запись</phrase>
  </command>
</commandGroup>
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Checking pressing
« Reply #26 on: January 31, 2015, 02:06:54 PM »
Этот хук может отследить время удержания кнопки? 1 сек 2 сек?

the "Hook" plugin can keep track of time holding the button? 1 sec 2 sec?

Yes and no. It would be better if we understood why you want to do this. There may be a better method to accomplish the same result.

However, without understanding the objective:

If you use the "Hook" plugin in combination with the "Python" plugin, you can probably keep track of time holding the button.

Example: (Python plugin must be enabled in "Options". Python is needed for the calculation.)

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.6-->
<commandGroup open="True" name="Time in seconds" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="288" name="z key pressed" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>zKey</param>
        <param>{DtCustom.mss}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>Hook.Z</event>
  </command>
  <command id="294" name="z key released" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>result={DtCustom.mss}-{var.zKey}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Time z key was pressed: {LastResult} seconds</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>Hook.Z.Up</event>
  </command>
</commandGroup>

Currently, this only works with single keys because you need to calculate the time between the "Hook.[key]" event and the "Hook.[key].Up" event.

This is because the "Hook" plugin does not generate a "Hook.[key+key].Up" event right now.

I think there is probably a different way to accomplish what you want that will be less complicated.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

NooBAsTiK

  • Jr. Member
  • **
  • Posts: 33
  • Karma: 0
    • View Profile
    • SquaD Skulls
Re: Checking pressing
« Reply #27 on: January 31, 2015, 02:14:02 PM »
Да у меня будет посложнее задача.
Кратно: Я играю в авиасимулятор и часто пользуюсь закрылками которые выпускаются от 0 до 60 градусов. Для себя определил 4 положения:
1. 0 градусов - полет
2. 8-9 градусов - боевое положение (время выпуска от 0 до 8-9 градусов около 3 секунд)
3. 17-18 градусов - взлет, маневрирование (от 8-9 около 5 секунд)
4. 50 градусов - посадка (от 18 около 9 секунд)

И вот тут получается следующий вопрос как выстроить логику:
Например я говорю "закрылки посадка"  надо держать кнопку 3+5+9=17 секунд, потом "закрылки боевое"  держать  кнопку которая убирает закрылки надо 9+5=14 секунд и так далее. Просто больше переменных делать?
Yes, I will be more difficult task.
Multiples: I play flight simulator and often use the flaps are released from 0 to 60 degrees. Set for ourselves four points:
1. 0 degrees - flight
2. 8-9 degrees - firing position (release time from 0 to 8.9 degrees for about 3 seconds)
3. 17-18 degrees - takeoff, maneuvering (from 8-9 for about 5 seconds)
4. 50 degrees - planting (approximately 18 seconds 9)

And here we have the following question is how to build the logic:
For example, I say "landing flaps" must hold the button 3 + 5 + 9 = 17 seconds, then "flaps combat" hold button which removes the flaps must be 9 + 5 = 14 seconds and so on. Just more variables do?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Checking pressing
« Reply #28 on: January 31, 2015, 02:17:06 PM »
Have you tried Phobophile's recommendation? Вы пробовали Phobophile рекомендации?

I thought he suggested a method using "maps" or "payload xml"?

---

One clarification about my example in the previous post. У меня есть еще одна вещь, чтобы объяснить, о мой пример в предыдущем посте ...

Переменная "{DtCustom.mss}" - это Текущее время в минутах и секундах. Если Текущее время 21:15:33, переменная "{DtCustom.mss}" = 1533.

"DtCustom" is an abbreviation for "Date" "Time" "Customization". We use Microsoft time variables: https://msdn.microsoft.com/ru-ru/library/8kb3ddd4(v=vs.90).aspx

« Last Edit: January 31, 2015, 02:22:02 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Checking pressing
« Reply #29 on: January 31, 2015, 02:34:47 PM »
I think voice control should be used to assist in flight simulation.  Some things are better done manually.

If I was playing a car driving game, I would not use voice control for steering.  I might use it for other things like gear up and gear down or for a quick look in the rear view mirror, so that I could keep my hands on the steering wheel.