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

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Magic
Posts: 31
Joined: 13 Jan 2012 21:45
Location: The Netherlands

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

Post 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!

admin
Site Admin
Posts: 64828
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

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

Post by admin »

You mean the selected file name? Or text in the clipboard? (The answer is "yes" in both cases.)

Magic
Posts: 31
Joined: 13 Jan 2012 21:45
Location: The Netherlands

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

Post by Magic »

I mean selected file (or folder) name :D

Can you elaborate on how to make that button?

highend
Posts: 14562
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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)...
One of my scripts helped you out? Please donate via Paypal

Irwin of Upton
Posts: 131
Joined: 28 Feb 2015 19:42

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

Post 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:

Magic
Posts: 31
Joined: 13 Jan 2012 21:45
Location: The Netherlands

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

Post 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?

highend
Posts: 14562
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post 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...
One of my scripts helped you out? Please donate via Paypal

Magic
Posts: 31
Joined: 13 Jan 2012 21:45
Location: The Netherlands

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

Post 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:

highend
Posts: 14562
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post by highend »

Sure it works. The question would have been: What did you do instead?^^
One of my scripts helped you out? Please donate via Paypal

Magic
Posts: 31
Joined: 13 Jan 2012 21:45
Location: The Netherlands

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

Post 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:

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

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

Post 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"

highend
Posts: 14562
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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

Post by highend »

just urlencode() the <curbase> variable and it should work as well
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4397
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

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

Post 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?

Post Reply