Quick web searches

I'll ask the addon's author if this is possible. Maybe I could make a request for this feature.

Thanks Opel. Much appreciated. I would think that this may be of use to others which is why I am not quite ready to give it up. If you often search for things with different search engines, this would be a valuable addition to your productivity toolbox. Or maybe it's just me... :slight_smile:

Thanks again for the quick replies. Let me know what I can do to help out to find a solution.

Easily done. This does Google and Bing. Add/change search engines as needed:

@set search = {dlgstring|Enter search term}
"https://www.google.com/search?q={$search}"
"https://www.bing.com/search?q={$search}"

Been doing the same for awhile as well...

I like to have whatevers in the clipboard added into the dialog by default by doing something like:

@set search = {dlgstring|Enter search term|{clip}}

You guys rock!!! :smiley:

I knew you'd come through. Thanks. It does exactly what I wanted! Ah, the joys of a great product with a great community...

Thanks again, Steje and Leo.

I personally prefer to use custom commands for this.

For example (Settings->Customize->Commands->User->Add)

  • Command1:
    name = g
    template = query
    tip = google search
    command:
    "C:\Program Files\Opera 9\opera.exe" "https://www.google.com/search?q=&query&
    
  • Command2:
    name = map
    template = query
    tip = google maps search
    command:
    "C:\Program Files\Opera 9\opera.exe" "https://maps.google.com/maps?q=&query&"
    

Next, drop a commands field from (Settings->Customize->Commands->Tools) in your GUI.

Next you can type g or map followed by your query in the command field. E.g.:

g test
g "test query"
map europe
etc...

For meta searches just insert multiple searches into the body of the custom commands.

Is it not possible to copy the selected text in any windows application and perform a Google search via a global key?

I tried the following but is not working:

Clipboard COPY
@set searchterm = {dlgstring|Enter search term|{clip}}
"http://www.google.com/search?q={$searchterm}"

Remove the "Clipboard COPY" line at the beginning of your button. It's trying to copy the selected file/s to the clipboard. The {clip} argument works independantly to the Clipboard command and simply provides any line with the current contents of the clipboard.

Great tip. I had a couple of queries that I hope that someone might clear up for me. :slight_smile:

  1. I managed to get google maps, dictionary, rotten tomatoes and wikipedia working using the technique that caine suggested. However, I can't get the IMDB string to work using the Url that steve suggested. http://www.imdb.com/Find?for=%s&select=All. I think its something to do with the %s.

  2. If entering more than one word, a result is not forthcoming from google unless it is enclosed in quotes. Is it possible to have the search term automatically enclosed in quotes? I tried:

"C:\Program Files\Mozilla Firefox\firefox.exe" "http://www.google.co.uk/search?q="&query&""

However, the second quote doesn't get put in at the end of the search term. Is it to do with having to use some kind of escape character at the end so that the penultimate quote is recognised as a string? I did the try the ' and / character, but neither of them worked. Apologies if this is a v basic question, but my experience of programming is v limited. :blush:

  1. Is it possible to have text (e.g. search box) pre-written within the command box. Once you press the mouse within the box, the text disappears so that you can type the search term?

Cheers! :slight_smile:

  1. The %s is what web browsers use for this type of thing but not what Opus uses. Instead of %s you need to use a code Opus recognises to insert the string you want to search for, like {file} or {clip} or {dlgstring} as in the examples in the thread.

  2. You need to URL-encode the quotes (i.e. use %22 instead of ") since they're in the middle of something that is already quoted:

    "C:\blah\Firefox.exe" "https://www.google.co.uk/search?q=%22moo cow%22"
    
  3. You mean on a toolbar? No, not currently.

Hi! Unfortunately, using %22 did not work. I created the following user command that can be invoked from the command field using g:

"D:\Program Files\Mozilla Firefox\firefox.exe" "http://www.google.co.uk/search?q=%22&quote&%22"

It opens firefox with the following URL:

http://www.google.co.uk/search?q=2&quote&2

Any suggstions would be appreciated. :slight_smile:

Turns out you have to double-up the % symbols, so use %%22 instead of %22.

I doubt those & symbols should be there either, by the way. & is used in URLs to separate arguments and needs to be escaped, like the " characters, if you want to include it in an argument.

You need to use the &'s if you're defining a user command, right? However, I cannot seem to get it to work either.

I had trouble getting the following to work:

"http://www.google.com/search?q=%%22&QUERY&%%22"

where QUERY is the template variable. However, this does not allow you to pass multiple strings in the QUERY (e.g. "g directory opus") without using quotes around the parameters. I finally :unamused: figured that all you you have to do is to define the template as QUERY/M.

So, define a User Command as follows:

Name: g
Template QUERY/M
Tip: Google Search
Function: "http://www.google.com/search?q=%%22&QUERY&%%22"

Now it works! :smiley:

And, as added bonus:

Name: drc
Template QUERY/M
Tip: Google Search
Function: "http://resource.dopus.com/search.php?search_keywords=%%22&QUERY&%%22"

Have fun with more...

Cheers,
Marcel

1 Like

Cheers m8! I will try this as soon as I get a chance. :o)

Sorry mvdlaan, I didn't realise you were trying to make a user command with argument template. The &-symbols you were using make perfect sense now.

Glad it's all working for you now!

Is it possible to use the custom searches we've already got saved in Chrome or Firefox with this?

For example, I've got "wiki" setup to search Wikipedia. "dopus" setup to search the Directory Opus forum. It always gets messy to duplicate all of these custom searches in another location. If there isn't a normal way to achieve this from the command line, any idea how to get that search engine configuration out of Chrome and Firefox and into a format easily usable by Opus?

From the forum, for Google, but should work for others (replace search-command and set button as script):

function OnClick(data) {
  data.func.command.ClearFiles();
  var objEnum = new Enumerator(data.func.sourcetab.selected);
  while (!objEnum.atEnd()) {
   var item = objEnum.item().name_stem; objEnum.moveNext();
   var encoded = encodeURIComponent(item);
   var search = encoded.replace(/%/g,"%%");
   data.func.command.RunCommand("http://www.google.de/search?q=" + search);
  }
}

I have written an elementary button JScript that performs web searches from within DOpus. It can use any number of search engines, which are easily configured into the script, and allows searching with one of those engines or with all of them at once. It also allows a choice from multiple browsers, which can also be configured into the script. This script may address some of the questions in the thread above.

It's not very elaborate, but because it is a script rather than DOpus code, I have posted it in the scripts forum instead of here. I hope it's useful to others.

@set searchterm = {dlgstring|Enter search term|{clip}}
"http://www.google.com/search?q={$searchterm}"

using above script the button actually pops up the clipboard text ..so i have to press enter and it opens in browser.
how to just open browser directly when pressing the button?

{dlgstring|...} is used to prompt you for input.

If you just want the clipboard text, use {clip} on its own.