Author Topic: The Alt-Tab problem via voice  (Read 5893 times)

0 Members and 1 Guest are viewing this topic.

Indy

  • $upporter
  • Jr. Member
  • *****
  • Posts: 23
  • Karma: 1
    • View Profile
The Alt-Tab problem via voice
« on: March 05, 2014, 01:35:13 PM »
I'm not sure if I'm not approaching this problem correctly, or I am missing something obvious.  I wish to setup a voice command to toggle Alt + tab as a simple example.  I want to continue holding alt while issuing a voice command to select next window via the Tab key.  Once I am overtop the desired window, I issue another command to select that window.  Here is how it works in my head.

Phrase: Switch Windows (inputkeys.keysDown Alt + inputKeys.Send Tab)
If Phrase Next (InputKeys.Send Tab)
elseif Phrase Select (inputKeys.keysUp Alt)

I can't figure out how to give another phrase in the if statement while inside a command.  Any working code you could provide is appreciated as it helps me learn from examples.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: The Alt-Tab problem via voice
« Reply #1 on: March 05, 2014, 01:43:10 PM »
Hi Indy,

It sounds like you're trying to use one command when you should be using three commands.

Command 1: Switch windows

Command 2: Next window

Command 3: Select

... James has xml for something similar on our htpc, but the computer is busy going through some therapeutic rituals right now, so I can't grab that command group to post. ;)


« Last Edit: March 05, 2014, 02:09:29 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)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: The Alt-Tab problem via voice
« Reply #2 on: March 05, 2014, 01:55:05 PM »
You could do something like this:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="Navigate windows" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="312" name="Switch windows" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>InputKeys.Send</cmdType>
      <cmdString>{CONTROL+LWIN}({TAB})</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Switch windows</phrase>
  </command>
  <command id="313" name="Next window" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>InputKeys.Send</cmdType>
      <cmdString>{RIGHT}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Next window</phrase>
  </command>
  <command id="328" name="Select" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>InputKeys.Send</cmdType>
      <cmdString>{ENTER}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Select</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: The Alt-Tab problem via voice
« Reply #3 on: March 05, 2014, 02:03:06 PM »
Just be careful, if you already have a voice command "Select" being used for another purpose you'll want to use a different phrase or VC will not be happy ...

Above, my 'next window' command is simply a right-arrow key emulation, which I think already exists in some of the standard configurations as "go right" or something like that, so technically you could just use that existing command (you could always add "next window" to the phrases for the existing command if you like).
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)

Indy

  • $upporter
  • Jr. Member
  • *****
  • Posts: 23
  • Karma: 1
    • View Profile
Re: The Alt-Tab problem via voice
« Reply #4 on: March 05, 2014, 02:54:04 PM »
Thanks nime5ster, didn't know about pushing ctrl as well would hold the selection window open, it works as expected.

Can phrases be bundled into an if statement like my example or is this not possible?  So the phase is directly connected to the previous command?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: The Alt-Tab problem via voice
« Reply #5 on: March 05, 2014, 03:15:10 PM »
Phrases are used specifically to trigger commands.

I guess one way in which you could have a phrase "directly connected to a previous command" is to have your first command enable a disabled group that contains other commands.

That seems like overkill for this particular case, but there are certainly scenarios where that would be a good way to make sure that VC isn't listening for a particular phrase unless told to do so.
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: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: The Alt-Tab problem via voice
« Reply #6 on: March 05, 2014, 05:36:57 PM »
Can phrases be bundled into an if statement like my example or is this not possible?

You can't put a command inside of another command.  That is not how it works.

When a command is triggered (either by you speaking, or by an event) it needs to execute and complete so that the program can start listening for the next command.  All that a command should do is perform actions and possibly change the "state of things" (like enabling a group) and then finish, hopefully without any major delays, because until your command completes the program is essentially FROZEN.

Indy

  • $upporter
  • Jr. Member
  • *****
  • Posts: 23
  • Karma: 1
    • View Profile
Re: The Alt-Tab problem via voice
« Reply #7 on: March 05, 2014, 06:22:52 PM »
Thank you both for the explanations.  Now that I understand the process, what about having sub phrases loaded based on the initial command.  Something where phrases could be reused but have different actions based based on what Action you are in.  So common words like next, or select could be used in natural situations where you would expect to make a choice, but depending on what you initiated or what is in focus it could have a different action.  I hope I explained it properly, and maybe I'm moving into a feature request.  I'm just bouncing the idea now to see what you guys think about it.

As I keep moving forward with it that I want my family and any guests at my house to be able to use it as natural as possible without training them on commands to use in certain situations.  My phrases are getting quite complex with lots of possible options now.  I quite often ask people that have never used Vox to ask the computer to do something and see how they approach it and build my phrases like that so that it can become as natural as possible.  I'm basically attempting to build a HAL 3000.  Regardless of the outcome, the software is amazing, I'm having a lot of fun playing with it, I want to automate everything with my voice now.

If you think 1) its plausible and 2) its worthwhile, I can start a new topic in Feature Request.  Don't want to waste anyone's time if I'm just not thinking the idea through completely and it doesn't make sense.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: The Alt-Tab problem via voice
« Reply #8 on: March 05, 2014, 07:01:57 PM »
This is what EnableGroups and DisableGroups is for.  It allows you to set a context.

Either that or you can set a variable and in your commands you can check the state of this variable to know what to do.

http://voxcommando.com/mediawiki/index.php?title=Actions#DisableGroup

https://www.google.ca/search?q=voxcommando+enable+disable+groups+site:voxcommando.com

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: The Alt-Tab problem via voice
« Reply #9 on: March 05, 2014, 07:06:16 PM »
I quite often ask people that have never used Vox to ask the computer to do something and see how they approach it and build my phrases like that so that it can become as natural as possible.  I'm basically attempting to build a HAL 3000.  Regardless of the outcome, the software is amazing, I'm having a lot of fun playing with it, I want to automate everything with my voice now.

This is very ambitious.  We obviously have a long way before we can really do this, but it doesn't hurt to try.  Slowly we will move towards it.  I don't pretend to think that I will be the one to get us there, but hopefully VoxCommando will help to further the movement a little bit, if only by inspiring future (smarter) programmers to try to improve on what we have done.  :D

Indy

  • $upporter
  • Jr. Member
  • *****
  • Posts: 23
  • Karma: 1
    • View Profile
Re: The Alt-Tab problem via voice
« Reply #10 on: March 05, 2014, 07:19:40 PM »
This is what EnableGroups and DisableGroups is for.  It allows you to set a context.

Either that or you can set a variable and in your commands you can check the state of this variable to know what to do.

http://voxcommando.com/mediawiki/index.php?title=Actions#DisableGroup

https://www.google.ca/search?q=voxcommando+enable+disable+groups+site:voxcommando.com

Wouldn't the Enable and Disablegroups still require a unique phrase or could I reuse a phrase that is for a different command and give it a different new action?

Indy

  • $upporter
  • Jr. Member
  • *****
  • Posts: 23
  • Karma: 1
    • View Profile
Re: The Alt-Tab problem via voice
« Reply #11 on: March 05, 2014, 07:30:12 PM »
This is very ambitious.  We obviously have a long way before we can really do this, but it doesn't hurt to try.  Slowly we will move towards it.  I don't pretend to think that I will be the one to get us there, but hopefully VoxCommando will help to further the movement a little bit, if only by inspiring future (smarter) programmers to try to improve on what we have done.  :D

Don't sell yourself short, it is very powerful as is, and with the logic builder, it is fairly user friendly.  Only reason I can do this is because of the Logic Builder.  If I needed to write code and get syntax correct, I would have given up long ago.

The more I can incorporate how people would naturally ask the computer to do something, the more user friendly it becomes and the more versatile so anyone can come in and work my media center.  Since it is a computer that shows my TV and not a cable or satellite box for TV, people that come to my house have never seen XBMC and are immediately intimated even with a remote, so I ask them to try and ask the computer to do what you want and I build my commands like that.  Also I'm terrible at memorizing exact phrases so I keep having to use OSD during commands to remind me and I'm starting to find overlap as I keep trying to make it natural language to accomplish tasks.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: The Alt-Tab problem via voice
« Reply #12 on: March 05, 2014, 07:35:37 PM »
I think at this point you'll need to do some reading of the documentation, as provided, and then some actual experimentation to understand what's possible and what's not.

Different groups can each contain some voice command phrases that are the same, as long as they are not active at the same time. By keeping those groups mostly disabled and only enabling them when you need them (after which they should be disabled again), you prevent the overlap that will confuse the program.

There are some examples on the forum, if you search a bit.

Nonetheless, this has to be done thoughtfully, and if you start to get a huge command tree I suspect you'll find it hard to keep track.

... If you're forgetting your commands a lot, I recommend creating a basic "show help" command so that you can quickly access the menu of all your commands when needed. http://voxcommando.com/mediawiki/index.php?title=Actions#Help

« Last Edit: March 05, 2014, 07:45:41 PM by jitterjames »
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)

Indy

  • $upporter
  • Jr. Member
  • *****
  • Posts: 23
  • Karma: 1
    • View Profile
Re: The Alt-Tab problem via voice
« Reply #13 on: March 05, 2014, 07:47:42 PM »
Yes was just going over it, I get how to do it now, just a lot of turning things on and off, I can accomplish what I want to achieve now as long as I map it all out properly.

Thanks again.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: The Alt-Tab problem via voice
« Reply #14 on: March 06, 2014, 05:42:37 AM »
You can use "optional" phrases in your commands to have more varieties to ask VC for a command, which allowed people to speak more naturally.

Example of asking VC to switch a light on:
Opt. phrase: please, can you, is it possible to
Normal phrase: switch, turn
Opt. phrase: the
Normal phrase: light,livingroom light
Normal phrase: on

In this example it is required to say the normal phrases to turn the light on but also you can use the optional phrases as varieties like - please turn the light on

You can read more about phrases here: http://voxcommando.com/mediawiki/index.php?title=Phrases
« Last Edit: March 06, 2014, 05:45:32 AM by Kalle »
***********  get excited and make things  **********