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

0 Members and 2 Guests are viewing this topic.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #15 on: June 18, 2015, 03:57:36 AM »
Great work, fantastic!   ::bow
***********  get excited and make things  **********

vcisawesome

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #16 on: June 18, 2015, 11:37:04 PM »
Wow,

This is excellent work. Thank you so much for this.

 ^-^


I have 2 questions as a followup:

1) Is there a way to run this outside the Robobrowser window; the reason I mention this is that I would have to close the tab from the search result in order to select another.

2) For scrolling on the results page (or any web page) I have noticed that when using the Sendkeys function there is no availability to use of the PageUP or PageDOWN key - unless I am mistaken; is there another way to get the use of these keys for web page navigation.


Once again many Thanx for the incredible work you have done. I am getting quite familiar with this software and am now at more than 90 commands and counting. When I show people a demonstration with VC coupled with the Ivona TTS voice responses people are in shear awe.


:clap


VCIA

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #17 on: June 19, 2015, 04:19:39 AM »
Ok, now I have add a new command, which allowed us to choose the next or previous result page.


here is a demo video which explain the commands: www.youtube.com/watch?v=FVJYs_Eqz7M


@VCIA: 1. A close "tab" command is already exist in the collection which close the RoboB window with the search results, then you can do another search and a new RoboB window will open. I have add also a "close result tab", which close the selected match tab in the chrome browser.
2. You can use a "SendKeys" action with {PGDN} or {PGUP}, but get sure you browser windows has focus  ;)

Here the Group_Collection (updated at 20.06.2015):

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.8-->
<groupCollection open="True" name="Web Search with RoboB and Google V3">
  <commandGroup open="True" name="Google search and scrape" enabled="True" prefix="" priority="0" requiredProcess="" description="">
    <command id="392" 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.SetWinSize</cmdType>
        <params>
          <param>1200</param>
          <param>1000</param>
          <param>390</param>
          <param>5</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Show</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Navigate</cmdType>
        <params>
          <param>https://www.google.com/search?q={1}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Wait</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>auto search</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>
    <command id="308" name="next result page" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
      <action>
        <cmdType>RoboB.Show</cmdType>
        <params>
          <param>True</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.ElementByID</cmdType>
        <params>
          <param>pnnext</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Click</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Wait</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>auto search</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>here are the next results</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <phrase>next result page</phrase>
    </command>
    <command id="334" name="previous result page" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
      <action>
        <cmdType>RoboB.Show</cmdType>
        <params>
          <param>True</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.ElementByID</cmdType>
        <params>
          <param>pnprev</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Click</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>RoboB.Wait</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>auto search</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>here are the previous results</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <phrase>previous result page</phrase>
    </command>
    <command id="425" name="return to 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.Show</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
      <phrase>return to search results</phrase>
    </command>
    <command id="389" name="auto rebuild results in payload xml for the current page" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
      <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>
      <event>auto search</event>
    </command>
  </commandGroup>
  <commandGroup open="False" 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, show me</phrase>
      <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\GoogleSearch.xml</payloadFromXML>
    </command>
    <command id="299" 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 result tab</phrase>
    </command>
  </commandGroup></groupCollection>
« Last Edit: June 20, 2015, 06:13:29 AM by Kalle »
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Select option 1-8 in Google search results
« Reply #18 on: June 19, 2015, 08:28:57 AM »

1) Is there a way to run this outside the Robobrowser window; the reason I mention this is that I would have to close the tab from the search result in order to select another.

2) For scrolling on the results page (or any web page) I have noticed that when using the Sendkeys function there is no availability to use of the PageUP or PageDOWN key - unless I am mistaken; is there another way to get the use of these keys for web page navigation.


Question 1.
...
It is a good start, but I think the only way to do it is with RoboBrowser and some very careful RegEx.

Question 2.

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

...

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.

The scrolling issue with RoboB windows will be addressed in the next  release. Generally speaking, however, page up and page down emulation does exist in all three keyboard emulation methods that VC supports. As Kalle says, you'll want to make sure the Chrome window is focused using the Windows.Focus action first.
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: Select option 1-8 in Google search results
« Reply #19 on: June 19, 2015, 08:54:03 AM »
the reason I mention this is that I would have to close the tab from the search result in order to select another.

It's not quite clear why this is, but I'm guessing that you mean that when a specific result opens in Chrome (or whatever your default browser is), the window opens on top of the RoboB window, hiding the search results page. Is that the issue?

If so, one easy solution is to add a "return to search results" type of command:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.8-->
<command id="411" name="return to 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.Show</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>return to search results</phrase>
</command>

That will bring the RoboB Google search results page to the front.
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: Select option 1-8 in Google search results
« Reply #20 on: June 19, 2015, 01:03:07 PM »
Ok, now I have add a new command, which allowed us to choose the next or previous result page.

here is a demo video which explain the commands: www.youtube.com/watch?v=FVJYs_Eqz7M

Great tutorial and demo Kalle.  :clap

I have only a couple of minor constructive criticisms to make it a bit better.

1 - You have an action RoboB.Select at the end of your command macro.  It doesn't make sense to put this at the end of a command.  It should always go at the beginning of the macro, before any other RoboB actions.

2 - Since you are already triggering the regex scan and payloadXML command using an "auto search" event for the "next result page" and "previous result page" it makes sense to use this same method for the initial search.  That way if you want to make any changes to the way the page is scanned and analyzed you only need to edit the actions in one place.  This is easier and helps to avoid errors.

So you could replace your original search with this one:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.5.0-->
<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.SetWinSize</cmdType>
    <params>
      <param>1200</param>
      <param>1000</param>
      <param>390</param>
      <param>5</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RoboB.Show</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RoboB.Navigate</cmdType>
    <params>
      <param>https://www.google.com/search?q={1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>RoboB.Wait</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.TriggerEvent</cmdType>
    <params>
      <param>auto search</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>search for, google search</phrase>
  <payloadDictation>payloadDictation: Regular</payloadDictation>
</command>

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #21 on: June 19, 2015, 01:36:39 PM »
Thanks James - you are right, RoboB.select is an accident by cloning the commands  :bonk


I think I did not understand the second part - can you show me on which place the "return to search result" must placed -I'm lost at the moment. ::duh
***********  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 #22 on: June 19, 2015, 03:10:32 PM »
You only need to look at the new version of the command I just posted to understand what I mean.

It has nothing to do with "return to search result"
« Last Edit: June 19, 2015, 03:23:13 PM by jitterjames »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Select option 1-8 in Google search results
« Reply #23 on: June 19, 2015, 04:20:34 PM »
Ahhhh sorry, now it is clear.
I have copied by mistake nime5ter code  :bonk


Again thanks, this makes absolute sense - I have updated the collection above: http://voxcommando.com/forum/index.php?topic=2208.msg19214#msg19214
and added also the "back to search result" feature from nime5ter.
« Last Edit: June 20, 2015, 06:18:23 AM by Kalle »
***********  get excited and make things  **********