Author Topic: Select option 1-8 in Google search results  (Read 8412 times)

0 Members and 1 Guest are viewing this topic.

vcisawesome

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
    • View Profile
Select option 1-8 in Google search results
« on: June 10, 2015, 06:04:03 PM »
Hello,

When I have Google Chrome open and have a google search results page I am unable to select Option 1 and so forth. I am trying to accomplish this as per this video: https://youtu.be/5zFoYdHiFgA?t=1m31s
but to no avail. A walk-through to set this up properly would be appreciated.

I have the full version 2.0.1.0 running on Windows 7.

Thanx in advance.



Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #1 on: June 10, 2015, 06:33:06 PM »
Did you checked this first?

http://voxcommando.com/mediawiki/index.php?title=Options#Show_OSD_alternates

Quote
Note that, by default -- even if it recognizes possible alternates -- VC will automatically execute the most likely command (i.e. Option 1). You can disable this by checking the "don't execute if there are alternate commands" box (see below).

VC version 2.0.1.0 is really old, why did you not update to 2.1.4.5 or 2.1.4.8?

http://voxcommando.com/home/downloads/
« Last Edit: June 10, 2015, 06:37:04 PM by Kalle »
***********  get excited and make things  **********

vcisawesome

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #2 on: June 10, 2015, 07:09:06 PM »
Hi Kalle,

I have checked the link you provided, when I say Select Option 1 - it repeats the previous VC command. I want to be able to click any of the link results via VC.


If I install the latest version of Voxcommando will I need another license key?


Thanx in advance.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #3 on: June 10, 2015, 07:42:26 PM »
Hi, no the key is the same and if you run the new version on the same machine, vc do not need a new activation.


Ahh, for what you looking for is complete different as what is showing in the video.
I'm not really sure, because I'm not at home to test it: maybe you can use input.keys actions for keyboard emulation


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


I think the best way to do is by using a scrape action with a result.regex action, but I can't show you the way yet, maybe tomorrow.

***********  get excited and make things  **********

vcisawesome

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #4 on: June 10, 2015, 08:13:24 PM »
Hi Kalle,

I have updated my VC to the latest version - I did not need the key and it works fine.

I thought about keyboard emulation but Chrome does not have a shortcut to open links in the results page.

I am interested in the scrape action with the result.regex action. I can't wait to see. I have been searching for how James did this (selecting Google results hyperlinks) but cannot find it.


I have watched the tutorial https://www.youtube.com/watch?v=G_tEroy_9Mw and am learning it but I would have thought there must be a Command that someone else wrote for this.


Look forward to hearing from you.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #5 on: June 10, 2015, 09:25:42 PM »
A other solution is to use a chrome plugin which generates for each entry a key - if you have this enabled you can use the Inputkey emulation, but only if the results have always the same key, but you can give it a try  ;)

https://chrome.google.com/webstore/detail/keyboard-navigation/abcekjakjehkpheoaadhkjfcdodpjbgk
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Select option 1-8 in Google search results
« Reply #6 on: June 11, 2015, 07:51:39 AM »
I was not selecting hyperlinks in the video.  I was always using alternates if the recognition engine's best guess was wrong. 

Yes.  Option 1 will always repeat the command.  This is how alternates in VC are designed to work.

The fact that I'm using alternates may not be so obvious because the recording only captured a portion of my screen.
« Last Edit: June 11, 2015, 08:13:19 AM by jitterjames »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #7 on: June 11, 2015, 03:11:26 PM »
I was able to get it to "work" with the VC Robobrowser plugin, but the result tags are changing dynamically - in other words: It works only for the first entry correct, which is not helpful.
I will try to figure out if the scrape action with regex will work, but this take some time. Maybe Haddood can help a bit  ::)


I'm sure nime5ter can help with a solution, because she is the "scrape- and regex." Queen  :bignod
***********  get excited and make things  **********

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #8 on: June 11, 2015, 07:14:44 PM »
Ok guys, now I can proudly present a solution  8)

copy the command group code below in your VC command tree


This command group contain following commands:

1. A google search with payload dictation as example: "search on google first us president" - which open your browser and show you results from the first page of Google search. This command stores also the first 5 matches in a maptable.

2. Now you can choose a match by voice: "show me match 3" and the command open the link which is stored as match 3 in the current tab. If you want check the other matches, ask for a other match.

3. say: "close tab" to close the current tab

You can edit the actions by your self if you want use more then 5 matches - have fun  ;)


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.5-->
<commandGroup open="False" name="Google search and scrape" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="287" name="google search" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.SpeakSync</cmdType>
      <params>
        <param>searching for {1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.CreateTable</cmdType>
      <params>
        <param>search_results</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.OpenURL</cmdType>
      <params>
        <param>https://www.google.de/search?q={1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>https://www.google.de/search?q={1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>&lt;h3\sclass="\w+"&gt;&lt;a\shref="\Wurl\Wq=(.*?)&lt;</param>
        <param>{CR}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>search_results</param>
        <param>match 1</param>
        <param>{Match.1.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>search_results</param>
        <param>match 2</param>
        <param>{Match.2.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>search_results</param>
        <param>match 3</param>
        <param>{Match.3.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>search_results</param>
        <param>match 4</param>
        <param>{Match.4.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>search_results</param>
        <param>match 5</param>
        <param>{Match.5.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>here are the results which I have found for {1}.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>search for, search on google, google search</phrase>
    <payloadDictation>payloadDictation: Regular</payloadDictation>
  </command>
  <command id="309" name="show match X" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>InputKeys.Send</cmdType>
      <params>
        <param>{LCONTROL}({W})</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Get</cmdType>
      <params>
        <param>search_results</param>
        <param>match {1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>http://(.*?)&amp;</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.OpenURL</cmdType>
      <params>
        <param>{Match.1.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>show me, open</phrase>
    <phrase optional="true">match, entry, result</phrase>
    <payloadRange>1,5</payloadRange>
  </command>
  <command id="282" name="close tab" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>InputKeys.Send</cmdType>
      <params>
        <param>{LCONTROL}({W})</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>close tab</phrase>
  </command>
</commandGroup>
« Last Edit: June 17, 2015, 11:17:36 AM by jitterjames »
***********  get excited and make things  **********

vcisawesome

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #9 on: June 17, 2015, 02:17:09 AM »
Hi Kalle,

I have tried your function but it did not work. It opens a blank web page without any search results.

I was so excited to try it hoping it would work and I certainly appreciate your help - perhaps there is an additional function/plugin that is missing.


Please advise.

VCIA

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #10 on: June 17, 2015, 03:58:24 AM »
I tried it again and it works fine in my case.
What is the VC history window showing - any error?
Maybe you must change first the google search link in my the command, because it is "google.de" instead as "google.com".
You can also check what is saved as result in the maptable.

This command does not work with VoxCommandoSp version, because the SP version does not support payload dictation.
If you have run the SP version and you open the command editor, you will see the payloads in RED, which means this function is missing.
« Last Edit: June 17, 2015, 04:57:43 AM by Kalle »
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Select option 1-8 in Google search results
« Reply #11 on: June 17, 2015, 09:35:02 AM »
Kalle you must be testing from a different command that what is on the forum because the urls have odd tags around them that look like this:

Code: [Select]
[url]https://www.google.de/search?q={1}[/url]

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #12 on: June 17, 2015, 10:59:01 AM »
Ahh  damn, the command in my tree is correct. It looks like I have some problems to post code here in the forum (sometimes also the font size is different) - I have never set the odd tags  ::yikes

James, I can't edit the command above, because I'm not at home - maybe you can solve it for me  :hugs
I can show you this issue next time in a hangout, maybe you have an idea  ::saddest


@VCIA:  please change the URL in the command and I think then it will work
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Select option 1-8 in Google search results
« Reply #13 on: June 17, 2015, 11:15:55 AM »
OK, I removed the forum tags.

Now it will sort of work, but because of the way Google returns different types of results, you usually don't get the correct link for the match number you specify.  So it sort of works, but not really.

It is a good start, but I think the only way to do it is with RoboBrowser and some very careful RegEx.
« Last Edit: June 17, 2015, 11:18:16 AM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Select option 1-8 in Google search results
« Reply #14 on: June 17, 2015, 09:13:00 PM »
It seems nime5ter and I both had the same idea.  Here is a solution that is based on what we did separately.  When I started, I tried to adapt the excellent start that Kalle made, but it was not possible using scrape alone.  Eventually we ended up with this which is quite different, and relies only on a payloadXml command for selecting results after the search.

Make sure the RoboB plugin is enabled before trying to use this XML.

You start by asking:  "search for THING"
and then you can either say: "select result number 3" or "select result LINKTEXT" where LINKTEXT is what is shown in blue by google's result page.

It only uses major link results, not all the ads and subdomain results that you see at the top.  If someone wants to modify it to cover all the possible links that would be great.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.8-->
<groupCollection open="True" name="Web Search with RoboB and Google">
  <commandGroup open="True" name="Google search and scrape" enabled="True" prefix="" priority="0" requiredProcess="" description="">
    <command id="364" name="google search" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>searching for {1}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Select</cmdType>
        <params>
          <param>Google</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Navigate</cmdType>
        <params>
          <param>https://www.google.ca/search?q={1}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Wait</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Show</cmdType>
        <params>
          <param>True</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.SetWinSize</cmdType>
        <params>
          <param>1200</param>
          <param>1000</param>
          <param>390</param>
          <param>5</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.ElementByID</cmdType>
        <params>
          <param>rso</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.GetHTML</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Results.RegEx</cmdType>
        <params>
          <param>&lt;h3\sclass="r"&gt;&lt;a.onmousedown=.*?href="(.*?)"&gt;(.*?)&lt;/a&gt;&lt;/h3&gt;&lt;</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>PayloadXML.Clear</cmdType>
        <params>
          <param>payloads\GoogleSearch.xml</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <loop>
        <loopParams>
          <from>1</from>
          <to>{#M}</to>
        </loopParams>
        <loopActions>
          <action>
            <cmdType>PayloadXML.AddPair</cmdType>
            <params>
              <param>payloads\GoogleSearch.xml</param>
              <param>{Match.{j}.1}</param>
              <param>Number {j}</param>
              <param>False</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
          <action>
            <cmdType>PayloadXML.AddPair</cmdType>
            <params>
              <param>payloads\GoogleSearch.xml</param>
              <param>{Match.{j}.1}?</param>
              <param>{Match.{j}.2}</param>
              <param>True</param>
            </params>
            <cmdRepeat>1</cmdRepeat>
          </action>
        </loopActions>
      </loop>
      <action>
        <cmdType>Group.Rebuild</cmdType>
        <params>
          <param>google results by payload xml</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <phrase>search for, google search</phrase>
      <payloadDictation>payloadDictation: Regular</payloadDictation>
    </command>
    <command id="245" name="close search results" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
      <action>
        <cmdType>RoboB.Select</cmdType>
        <params>
          <param>Google</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Dispose</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
      <phrase>close search results</phrase>
    </command>
  </commandGroup>
  <commandGroup open="True" name="google results by payload xml" enabled="True" prefix="" priority="0" requiredProcess="" description="">
    <command id="410" name="select result" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>opening {PF.1}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Launch.OpenURL</cmdType>
        <params>
          <param>{1}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <phrase>select result</phrase>
      <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\GoogleSearch.xml</payloadFromXML>
    </command>
  </commandGroup>
</groupCollection>

In the process of making these commands I discovered some small things that will be improved in the next release of VC.

In the main program, payloadXML files won't work as expected if two payloads have exactly the same value.  I did this on purpose back in the day but now I realize that there are valid reasons for allowing it.  As a work around I added a ? to the end of the value for the title based URL.  (You need to look at the macro to understand what I'm talking about.)

In roboBrowser I'm going to improve the focusing of the browser window to make it easier to send the RoboB keyboard emulation, and I'm adding actions to scroll the window.
« Last Edit: June 17, 2015, 09:19:27 PM by jitterjames »