microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
108.27k stars 6.39k forks source link

[Run][New Plugin] Web search #3245

Closed mrlacey closed 2 years ago

mrlacey commented 4 years ago

Summary of the new feature/enhancement

I want to be able to start a web search from the launcher. Ideally, I'd type bing power toys and it would navigate to https://www.bing.com/search?q=power+toys in my default browser. google power toys would go to the equivalent.

The ability to specify the keyword/search engine to use and the domain it goes to would also be necessary. Not only would this enable supporting other search engines, but it would also allow for people to adjust for different TLD versions of search engines.

This would be similar to functionality that used to be available in Enso launcher.

Proposed technical implementation details (optional)

This would presumably require some settings for determining which words are identified as initiating the search and the URL to submit the query to. This could also be the base for similar functionality where a keyword could launch an app and pass other values as command-line arguments. Without additional arguments, this could also serve as a way to create aliases for apps so they could be launched with a small number of keystrokes.

crutkas: possible solution to this issue in #10619. It defers to default browser + user's search engine. Lets PT Run be generic

ArttuLai commented 4 years ago

Yes! Also it would be great if I could just write a longer sentence/string and it would always default to web search when it doesn't find other results. So basically, it should be like Windows Search πŸ˜…

CatSlave007 commented 4 years ago

This function is very practical. Hope to realize it

YongWookHa commented 4 years ago

Yes, just like Alfred on Mac does!

rglastra commented 4 years ago

So basically, it should be like Windows Search

And it would be fantastic if it would leverage the system default browser's chosen search engine, instead of picking one for itself.

ChristophRichner commented 4 years ago

How about using a ? char to to switch to a web search mode like > goes to a shell?

zakius commented 4 years ago

that could be a shortcut to default search engine, but multiple ones should be supported with own keywords

kraoli commented 4 years ago

Please give the option to disable this. Not everyone wants to automatically expose every local search query to a search engine on the internet.

This is, by the way, a big privacy insult in the windows start menu search, because you can't disable web search anymore.

Absoblogginlutely commented 4 years ago

See also #3420 that someone posted. I have a ton of web shortcuts in the browser and it would be nice to be able to run them natively in the launcher, optionally with the ? or # or other user defined character beforehand so powertoys understands I'm gong to be running a search engine. One thing to consider would be how it knows which browser to use - to further muddy the waters would modifiers launch a particular browse so '# c powertoys' launches chrome (the 3) and then runs the c shortcut to search chocolatey's website for powertoys. Using '? int passwords" would then launch edge to search the intranet for passwords (as an example)

ZaninAndrea commented 4 years ago

Please give the option to disable this. Not everyone wants to automatically expose every local search query to a search engine on the internet.

This is, by the way, a big privacy insult in the windows start menu search, because you can't disable web search anymore.

While windows search automatically loads the results the proposed functionality here is having the option to search your query through PowerToys Run, but it would not do that automatically, you still need to hit enter on the web search option, so all your queries remain private unless you explicitly ask to open a browser and search on google.

ZaninAndrea commented 4 years ago

One thing to consider would be how it knows which browser to use

The query "> url" already opens a url in the default browser, so I think the issue of detecting which browser to use has been already solved

zakius commented 4 years ago

it just uses system call run or anything like that and OS itself resolves that

SaschaKrug commented 4 years ago

Would love to see this:

With keywords b, g, d for doing a query in the corresponding search engines and listing the results.

As a last resort if nothing could be found, on enter send query to default search engine

kraoli commented 4 years ago

, but it would not do that automatically, you still need to hit enter on the web search option, so all your queries remain private unless you explicitly ask to open a browser and search on google.

Yes, as a possibility it's a feature. I thought about getting web results as soon as you start typing or doing a web search automatically in addition.

I think it's a very dangerous idea to force web results in a local search without an option to disable it, like the Windows search is doing it since some versions. It's a possible way to leak information unwanted from your computer. You could disable web search in the past, but it was removed some versions ago. On macOS you can set the search providers for the search like you want: only local, with web search, with wikipedia,... That's the better approach and everyone can set it up like wanted.

shirkerohit commented 4 years ago

One thing to consider would be how it knows which browser to use

The query "> url" already opens a url in the default browser, so I think the issue of detecting which browser to use has been already solved

Thanks for the tip! but You need to prefix it with "WWW" 😞 . If I am not wrong! I think having identified that entered text is an URL opening that with the default browser will be a clean approach.

Jay-Squared commented 4 years ago

I am a big fan of the implementation of the web search functionality in Wox, where the user can define any random search using keywords and search URLs. So I have, for example, a web search to search Canadian case law using the https://www.canlii.org/en/#search/id={q} search URL, and I can trigger that by typing "canlii" plus the search query, then there is another search in the English Wikipedia using "wen" and the https://en.wikipedia.org/wiki/{q} search URL, or a third one searching in the German Wikipedia using "wde" and the https://de.wikipedia.org/wiki/{q} URL.

Praful commented 4 years ago

There's lots you can do here. Rather than get bogged down in detail, how about this basic functionality for a first version:

  1. User presses <Alt><Space>.
  2. User starts typing in the edit box. Power Toys Run displays what it currently displays from the shell. No change.
  3. If the user presses <Enter>, Power Toys Run does what it currently does. No change.
  4. If the user presses <Ctrl><Enter>, Power Toys Run opens the default browser, passes the string from the edit box to the default search engine and the search results are shown in the browser.

This is roughly what Google Desktop for Windows used to do before it was discontinued. It gives us a quick way to search for something on the web. I suspect it's the primary use case.

The one complexity is that I'm not sure the user's default search engine is discoverable without custom code for each browser. In which case, one of the settings in Power Toys would be to choose a default search engine. Version 1 can have a list of pre-defined ones (not customisable) to keep it simple.

Version 2 can introduce custom search engines and more sophisticated ways of searching the web such as prefixing the search by a letter (alias) to use a particular web site eg

b <search string> to search using Bing w <search string> to search Wikipedia

and so on. For this, the Settings would allow the addition of aliases, such as:

Alias  URL
b      https://www.bing.com/search?q=%1
g      https://www.google.com/search?q=%1
w      https://en.wikipedia.org/wiki/%1
a      https://smile.amazon.co.uk/s?k=%1

where %1 is replaced by the search term entered by the user.

For version 3, you could have the option of including web history as the user typed a search term.

nor0x commented 4 years ago

@Praful

There's lots you can do here. Rather than get bogged down in detail, how about this basic functionality for a first version: ...

i think this is a great idea to have aliases. I like syntax of DuckDuckGo Bangs which have a leading ! to distinguish a command from a regular input.

info: https://duckduckgo.com/bang

xmha97 commented 4 years ago

Auto complete feature is necessary. Please see this issue: https://github.com/microsoft/PowerToys/issues/4531

starfishpatkhoo commented 4 years ago

One can get PTRun to launch web URLs using a work around. Just documenting it here for reference if other people search and hit this page.

Summary

Firstly. we need to choose a prefix. In my example below, I use g as the prefix. Then, create an exe or batch file using this prefix, ie, g.exe, g.cmd or g.bat. However, if it is a batch file, then PTRun will require you to specify the extension as part of the prefix. You can choose gl.exe or web.exe or whatever you like for your prefix/program. Just don't have it clash with another existing program or prefix.

Secondly, this prefix exe or batch file needs to be in your path environment. For this example, I use %LOCALAPPDATA%\Microsoft\WindowsApps, but it works equally well if you choose C:\Windows\System32 (but I don't recommend it).

Finally, in order for PTRun to pass on the url parameter, we need to tell it to use the command processor with the > prefix when calling it (as described in #3405 - @edhcah example with Notepad++ didn't work because notepad++.exe wasn't in the path)

Method 1 - Soft Linking directly to Chrome

  1. Open an Admin Command Prompt
  2. cd "%LOCALAPPDATA%\Microsoft\WindowsApps"
  3. mklink g.exe "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
  4. mklink chrome_proxy.exe "C:\Program Files (x86)\Google\Chrome\Application\chrome_proxy.exe" (needed for Chrome to work)
  5. Test it out in PTRun:

Method 2 - Batch File for Default Browser

If you prefer to use the system default browser, or do not wish to create symlinks, then you can add this batch file into %LOCALAPPDATA%\Microsoft\WindowsApps

  1. Create a new file %LOCALAPPDATA%\Microsoft\WindowsApps\g.cmd
@echo off
set _url=%1
if /I "%_url:~0,4%"=="http" (
    start "" %_url%
) else (
    start "" https://%_url%
)
  1. Test it out in PTRun:

Next Step

One can of course convert the batch file to a proper CLI exe or extend it to do a Google search, but this solution is merely an interim hack until PTRun has proper support for this feature. In the mean time, this same principle can be used for other browsers/programs/etc, etc. For example, you can modify this concept to launch python scripts (via python.exe in %LOCALAPPDATA%\Microsoft\WindowsApps) or WSL shell scripts via wt.exe (eg. start/stop WSL httpd/MariaDB services from PTRun).

Tested working in version PT 0.19.2 / Chrome 83

shirkerohit commented 4 years ago

I am just wondering, Why wouldn't I though about It, I had kept chrome as my startup program and had set my email domain as the default page. πŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈ

bnewcomb commented 3 years ago

I'd like to see functionality similar to Launchy, where a string is detected as potentially searchable and the actions available for that string appear below in the search results. Those actions could be customized by the user, including some of the more advanced cases I've read from everyone. i.e. Targeted browser, engine or as input to interpolation, lexing and/or semantic analysis.

This approach acknowledges privacy concerns for out of box functionality. Customization involving downstream analysis would be a risk for the user or org to take on.

eiis1000 commented 3 years ago

Would love to see this as well! I think the ? idea is particularly clean.

TotalChris commented 3 years ago

To throw in my two cents, I typically enjoy the Windows Search functionality, where a query that isn't recognized as anything else gets passed to a web search. I press one key, type my query, then hit enter and I immediately have the web results. I barely think about it. Only change I would make is browser/search engine choice. Obviously, restriction to Bing or Edge would be frowned upon in this project.

shirkerohit commented 3 years ago

Yeah, I am expecting something like image and may be in setting we can have option to enable/disable web search!

50l3r commented 3 years ago

something new? not possible to search with google at the moment?

Cdddo commented 3 years ago

The ability to define custom web queries is one of the simplest and most useful features for a launcher like this... see Wox or Alfred on Mac.

In my opinion custom alias should not have a hardcoded prefix like ! or ? or #. If people want that they can add them to their alias, but we shouldn't be forced to use them.

carter-lavering commented 3 years ago

My two cents: A ? prefix would definitely be better than nothing, but personally I prefer having a dedicated "launch web search" keyboard shortcut. Shift+Enter (for instance) right after my query feels much faster than typing a question mark and an additional space at the beginning.

CursedSoulOfGods commented 3 years ago

I think so a possible way to do so is get the query written inside the search box and add the selected search engine query to it. So for example if the user enters google power toys than the google keyword can be detected and removed. Than using the detected google keyword, the search engine link can be added into the ammended string, so it becomes 'https://www.google.com/search?q=power toys', the space is automatically replaced with %20 by the browsers. This can then be transferred to the shell where it will open the link up in the default browser

AW1534 commented 3 years ago

Please give the option to disable this. Not everyone wants to automatically expose every local search query to a search engine on the internet.

This is, by the way, a big privacy insult in the windows start menu search, because you can't disable web search anymore.

@kraoli

there shouldn't be a preview of the search, so the query only gets exposed when you press on it. but yes, an option to disable it would definitely be nice

edit: clarity

Whatssam commented 3 years ago

Definitely there should be the possibility like in Wox for Windows and Alfred for MacOS to just type a query and already get possibility to look it up on a preselected browser (PLEASE USE CHROME, NOT EDGE) most importantly when the query does not match any other possible request e.g. looking for a file, app, etc.

I think that adding the keyword like (g what is.....)would be a waste of time because it's faster and more practical to just write what you are looking for.

Maybe also add the possibility to search for a query on private tabs

owensco commented 3 years ago

+1 for this feature.

I would like this to work similarly to Alfred (on mac): if your local search does not return anything, hitting enter will launch the browser, and search your query on google.

A toggle for this makes sense as well :)

gdlazcano commented 3 years ago

+1 for this feature. This should definitely be an option.

smuun commented 3 years ago

For people looking for a quick fix, here's an autohotkey script that will replace qq with the google search URL inside powertoys run.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#IfWinActive, PowerLauncher
:*:qq::https://www.google.com/search?q=
benjamhooper commented 3 years ago

@crutkas @enricogior Would you be comfortable with me porting the Wox.Plugin.WebSearch, as I did with Wox.Plugin.Sys?

engrbugs commented 3 years ago

For people looking for a quick fix, here's an autohotkey script that will replace qq with the google search URL inside powertoys run.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#IfWinActive, PowerLauncher
:*:qq::https://www.google.com/search?q=

How would we run this in Power Toys Run?

micahmo commented 3 years ago

How would we run this in Power Toys Run?

@engrbugs The macro replaces the current query text (iff PowerToys Run is the active window) with the basic Google search query string. Then you can type your query and press Enter. PowerToys Run detects it as a URL and opens it in the browser.

engrbugs commented 3 years ago

@micahmo Thanks! I installed AHK and put the scripts in the Windows Startup folder. I added some in the script:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#IfWinActive, PowerLauncher
:*:qq::https://www.google.com/search?q=
:*:tt::https://www.thesaurus.com/browse/
:*:yt::https://www.youtube.com/results?search_query=
CursedSoulOfGods commented 3 years ago

@micahmo Thanks! I installed AHK and put the scripts in the Windows Startup folder. I added some in the script:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#IfWinActive, PowerLauncher
:*:qq::https://www.google.com/search?q=
:*:tt::https://www.thesaurus.com/browse/
:*:yt::https://www.youtube.com/results?search_query=

What is AHK and @micahmo, how to implement this. Is this a script that just needs to be put in notepad and saved. But then what is the extension of the script to be saved. Is it so that it is a script that when put in the startup folder, launches at startup, checks if power run is the active window and then replaces the text 'qq' with the google search url? What is the extension of the script and what is AHK?

micahmo commented 3 years ago

@cursedsoulofgods

What is AHK

AHK or AutoHotkey is a powerful scripting utility, most often used for macros and custom keybinding. Download here.

Is this a script that just needs to be put in notepad and saved.

Yep.

But then what is the extension of the script to be saved.

AutoHotkey scripts have .ahk extension.

Is it so that it is a script that when put in the startup folder, launches at startup

Exactly. To activate a script, you just run it (assuming the .ahk extension is linked to the application), or put it in the startup folder so that it runs automatically. You should also see an icon the system tray for each active script, where you can pause/quit/etc.

checks if power run is the active window and then replaces the text 'qq' with the google search url?

Yes, that's what @smuun's script does when active.

BTW, Windows startup folder is either %appdata%\Microsoft\Windows\Start Menu\Programs\Startup for the current user, or %programdata%\Microsoft\Windows\Start Menu\Programs\StartUp for the all users.

CursedSoulOfGods commented 3 years ago

In reply to @micahmo reply to my comment

assuming the .ahk extension is linked to the application

What do you mean by the AHK being linked to the application? Are there any special procedures for it?

micahmo commented 3 years ago

@cursedsoulofgods

assuming the .ahk extension is linked to the application

What do you mean by the AHK being linked to the application? Are there any special procedures for it?

Sorry, I should've omitted that statement as it's more confusing than helpful. :) If you install AutoHotkey, it will automatically become the default application for .ahk files.

CursedSoulOfGods commented 3 years ago

@cursedsoulofgods

assuming the .ahk extension is linked to the application

What do you mean by the AHK being linked to the application? Are there any special procedures for it?

Sorry, I should've omitted that statement as it's more confusing than helpful. :) If you install AutoHotkey, it will automatically become the default application for .ahk files.

Ok thanks @micahmo

engrbugs commented 3 years ago

Hey guys, I created a Python script for those who do not like AutoHotkey running in the background. Here: https://github.com/engrbugs/powertoys-run-browse

CursedSoulOfGods commented 3 years ago

Hey guys, I created a Python script for those who do not like AutoHotkey running in the background. Here: https://github.com/engrbugs/powertoys-run-browse

Hey @engrbugs I went through your script. What it really does it that it launches the browser. No offense, I find your script to be kinda useless. Not being rude here, the thing is one can simply type their browser name and search or they can just type "www.google.com" and search. So yeah, maybe if you can collect the keyword inside the search box and then pass it would be much more helpful because what you have done is just simply made an app that searches, nothing else. Please work on it. I really appreciate your effort into this, thanks!

engrbugs commented 3 years ago

Hey guys, I created a Python script for those who do not like AutoHotkey running in the background. Here: https://github.com/engrbugs/powertoys-run-browse

Hey @engrbugs I went through your script. What it really does it that it launches the browser. No offense, I find your script to be kinda useless. Not being rude here, the thing is one can simply type their browser name and search or they can just type "www.google.com" and search. So yeah, maybe if you can collect the keyword inside the search box and then pass it would be much more helpful because what you have done is just simply made an app that searches, nothing else. Please work on it. I really appreciate your effort into this, thanks!

None was taken. Thank you for the feedback. As I said, this is not for everyone. I created this script because I do not want AHK running on my background. Thus, I am this sharing and open-sourced to everybody.

CursedSoulOfGods commented 3 years ago

Hey guys, I created a Python script for those who do not like AutoHotkey running in the background. Here: https://github.com/engrbugs/powertoys-run-browse

Hey @engrbugs I went through your script. What it really does it that it launches the browser. No offense, I find your script to be kinda useless. Not being rude here, the thing is one can simply type their browser name and search or they can just type "www.google.com" and search. So yeah, maybe if you can collect the keyword inside the search box and then pass it would be much more helpful because what you have done is just simply made an app that searches, nothing else. Please work on it. I really appreciate your effort into this, thanks!

None was taken. Thank you for the feedback. As I said, this is not for everyone. I created this script because I do not want AHK running on my background. Thus, I am this sharing and open-sourced to everybody.

No problem buddy. Also, I am pretty new to github so what does "None was taken" mean?

msc94 commented 3 years ago

I have a very basic version of this ready I'm using for myself. If it's likely to be merged I can create a PR for this.

4C3rXRDDgN

enricogior commented 3 years ago

@masi456 before opening a PR, can you open a new issue dedicated to discuss the details of your implementation? It would be useful if you can document the design and what configuration options it supports.

moishinetzer commented 3 years ago

It would be great to have an option in settings to make your own custom search queries for example "a QUERY" to search amazon, or "y QUERY" to search youtube and such

suttonbradley commented 3 years ago

It would be even better to support (optionally) using your default browser's custom search engines as well, as someone who uses "g" then tab for Google search, "yt" then tab for YouTube, "maps" then tab for Google Maps, etc. in order to prevent the step of duplicating all of those across into PowerToys.