Page 1 of 1

Is it possible to copy text to Google search with a button?

Posted: 25 Oct 2016 20:36
by Magic
Hi there,

long time no question :tup:

But I do have a new one: is it possible to make a button that copy's the selected text right into Google search?

cheers!

Re: Is it possible to copy text to Google search with a butt

Posted: 25 Oct 2016 21:34
by admin
You mean the selected file name? Or text in the clipboard? (The answer is "yes" in both cases.)

Re: Is it possible to copy text to Google search with a butt

Posted: 25 Oct 2016 21:58
by Magic
I mean selected file (or folder) name :D

Can you elaborate on how to make that button?

Re: Is it possible to copy text to Google search with a butt

Posted: 25 Oct 2016 22:07
by highend
With "google search" you mean the search bar (normally next to the addressbar) of a browser?
Not without external help (vbscript / ahk / autoit)...

But to just open an url with a search param, something like this would work (it uses
the name of the current selected file / folder as the search parameter):

Code: Select all

    $query = quote("https://www.google.com/search?q=" . urlencode(<curbase>));
    run """D:\Users\Highend\Tools\Firefox\App\Firefox.exe"" -url $query", "<xypath>";
Ofc you need to adapt your path to ff.

"open" as a script command would work as well if the browser is the default (registered) browser (mine isn't, hence the run command)...

Re: Is it possible to copy text to Google search with a butt

Posted: 26 Oct 2016 15:39
by Irwin of Upton
This is a nice function to have in the toolkit. Do exactly this with some frequency manually but never ever thought of a script for it. :appl:

Re: Is it possible to copy text to Google search with a butt

Posted: 26 Oct 2016 18:17
by Magic
There must be something simple I miss...

When I copy/paste your lines (with the adapted path) in scripting --> run script, it work flawless! :tup:

But somehow I do not get the script to work with a button :(

What I did:
user - manage commands - run script - Action (run specified script) - Caption (Search Google) - Script (the whole copy/paste)
I do get an commandID which I assigned to a button, but the button does nothing....

What am I missing?

Re: Is it possible to copy text to Google search with a butt

Posted: 26 Oct 2016 20:46
by highend
User IDs can be executed? Never stumbled upon this one^^

Put the script in a script file (.xys), put in the XY script folder,
load it from a button / UDC - Load Script File

e.g. via:

Code: Select all

<xyscripts>\googlesearch.xys
Or however you named it...

Re: Is it possible to copy text to Google search with a butt

Posted: 26 Oct 2016 22:12
by Magic
Highend,

even with your explanation it did not work... :oops:

But with the tutorial from: viewtopic.php?p=53748#p53748
I got it to work! So thanks a million in pointing me in the (very) right direction! :tup: :tup:

Re: Is it possible to copy text to Google search with a butt

Posted: 26 Oct 2016 22:18
by highend
Sure it works. The question would have been: What did you do instead?^^

Re: Is it possible to copy text to Google search with a butt

Posted: 27 Oct 2016 06:07
by Magic
Probably something wrong :wink:

I'm a script n00b all the way so bare with me...

Either way I got it to work :tup: :appl:

Re: Is it possible to copy text to Google search with a butt

Posted: 19 Jul 2017 18:06
by yusef88
highend wrote:

Code: Select all

    $query = quote("https://www.google.com/search?q=" . urlencode(<curbase>));
    run """D:\Users\Highend\Tools\Firefox\App\Firefox.exe"" -url $query", "<xypath>";
why does it omit words after The ampersand ?
if base name is "windows & linux" the search query will be "windows"

Re: Is it possible to copy text to Google search with a button?

Posted: 19 Jul 2017 18:25
by highend
just urlencode() the <curbase> variable and it should work as well

Re: Is it possible to copy text to Google search with a button?

Posted: 20 Jul 2017 13:56
by klownboy
highend wrote:User IDs can be executed? Never stumbled upon this one^^
Sure can. I've been calling some from an AHK script. They work fine.

Code: Select all

Run, D:\Tools\XYplorer\XYplorer.exe /script=::#1400,,,PID
...even cruising the Mediterranean. :)
I do get an commandID which I assigned to a button, but the button does nothing....
Hi Magic, did you place the # symbol before the command ID in the On left-click Edit field?