Hotkey to search current text selection?

Discussion related to "Everything" 1.5.
Post Reply
wkearney99
Posts: 28
Joined: Sun Nov 07, 2021 2:42 pm

Hotkey to search current text selection?

Post by wkearney99 »

Is there a way to tell Everything to search using the currently selected text?

As in, have a string selected somewhere, like a browser or text editor, and tap a hotkey to have it bring up Everything and search on that selection?

I know I can (and have) map a hotkey to bring up Everything using the Tools->Options->Keyboard settings.

But I'm unclear on how to have a current selection automagically pasted and searched. I can, of course, do a Ctrl-C to copy the text, hit the Search key on the keyboard (maps as 'Browser Search') then paste, then hit return. I'm just wondering if I'm missing something that's already been done for Everything.

I figured it best to ask her before I go reinvent the wheel (badly) using autohotkey.
NotNull
Posts: 5961
Joined: Wed May 24, 2017 9:22 pm

Re: Hotkey to search current text selection?

Post by NotNull »

Yes, there are several ways.
A couple of ways are described here.

Another option:SnipDo, described here and here

Or use the clipboard functionality of Everything. Described here.

There might be even more. Do a forum search for those.
tuska
Posts: 1375
Joined: Thu Jul 13, 2017 9:14 am

Re: Hotkey to search current text selection?

Post by tuska »

Text editor - EmEditor
- [Mark] word(s) in EmEditor (for a word, it is sufficient to position the cursor in the word).
- Press the 'Everything' button in EmEditor | "Assign Keyboard Shortcut..." is also possible in EmEditor.

'Everything' is opened and the search text is automatically entered in the ‘Everything’ search box.
 
2025-01-23_Text editor - EmEditor.png
2025-01-23_Text editor - EmEditor.png (111.38 KiB) Viewed 3116 times
 ____________________________________________________________
Windows 11 Pro (x64) Version 24H2 (OS Build 26100.2894) - 2025-01-14
'Everything' 1.5.0.1391a (x64) - "Portable on system drive C:"
Xavierarmand
Posts: 38
Joined: Fri Nov 24, 2023 12:19 am

Re: Hotkey to search current text selection?

Post by Xavierarmand »

@wkearney99

i have these two hotkey set up in my AHK v1 script that i use daily. the copy [ Selected Text ], and use the CLI to open a new tab in everything and then restores the clipboard. Win+F does a normal EV Search, Shift + Win + F does a System Index search in EV.

learning AHK is pain in the butt. drove myself CRAZY with it for a year before the basics started to make sense.
thou after a while i don't know how i computed without it.

viewtopic.php?p=65959#p65959

Code: Select all

#f:: ; Win + F -- Search selected text via {clipboard} in everything 1.5a
Findwitheverything:
    ClipSaved := ClipboardAll
    sleep 400
    Clipboard := ""
	sleep 80
    Send ^{vk43} ;Ctrl C
    ClipWait 0.5
	if ErrorLevel
		{
			Tooltip, Failed to Copy Text.
			Sleep 2000
			Tooltip
			clipboard := ""
			sleep 250
			clipboard := ClipSaved
			Return
		}
	sleep 50
	run, "C:\Program Files\Everything 1.5a\Everything64.exe" -newtab -s "%clipboard%"
	sleep 800
    clipboard := ""
    sleep 80
    clipboard := ClipSaved
	sleep 400
return
}

#+f:: ;; Shift + Win + F -- Search selected text in the System Index in everything 1.5a
evindex:
    ClipSaved := ClipboardAll
    sleep 400
    Clipboard := ""
	sleep 30
    Send ^{vk43} ;Ctrl C
    ClipWait 0.5
	if ErrorLevel
		{
			Tooltip, Failed to Copy Text.
			Sleep 2000
			Tooltip
			clipboard := ""
			sleep 250
			clipboard := ClipSaved
			Return
		}
	run "C:\Program Files\Everything 1.5a\Everything64.exe" -newtab -s* si*: """"%clipboard%""""
	sleep 800
    clipboard := ""
    sleep 80
    clipboard := ClipSaved
	sleep 400	
return

wkearney99
Posts: 28
Joined: Sun Nov 07, 2021 2:42 pm

Re: Hotkey to search current text selection?

Post by wkearney99 »

#clipboard: is VERY useful. Great for leaving EV open but not the foreground app and then just copying the relevant text for searching.
wkearney99
Posts: 28
Joined: Sun Nov 07, 2021 2:42 pm

Re: Hotkey to search current text selection?

Post by wkearney99 »

Xavierarmand wrote: Fri Jan 24, 2025 1:28 am learning AHK is pain in the butt. drove myself CRAZY with it for a year before the basics started to make sense.
You are SO right about that.

Does yours always spin up another exe of everything for each search? Or is EV smart enough to avoid multiple instances? I don't want to end up closing a whole bunch of EV windows/tabs over and over.

I know AHK has some windows title or class checking features which might be relevant to this. As in, if there's not already an EV window open, fire up the exe command line, otherwise, use that existing window for searches. I'm not worried about stepping on any existing window results, but I could see how others might.
Xavierarmand
Posts: 38
Joined: Fri Nov 24, 2023 12:19 am

Re: Hotkey to search current text selection?

Post by Xavierarmand »

With the -newtab command it use existing window. And I believe that's a setting from the options panel from everything itself, which it great cause it leaves ahk out of it.
Xavierarmand
Posts: 38
Joined: Fri Nov 24, 2023 12:19 am

Re: Hotkey to search current text selection?

Post by Xavierarmand »

in everythings options, under General > UI

untick -- Create a new window when running Everything.
tick -- Open searches in tab


that keeps you from having a zillion EV windows open.
wkearney99
Posts: 28
Joined: Sun Nov 07, 2021 2:42 pm

Re: Hotkey to search current text selection?

Post by wkearney99 »

wkearney99 wrote: Fri Jan 24, 2025 4:17 pm #clipboard: is VERY useful. Great for leaving EV open but not the foreground app and then just copying the relevant text for searching.
Are there circumstances where EV will follow a URL when using #clipboard: ?

I was wondering why EV was seeming slow at times, and it appears it was following URLs that were on the clipboard? But I can't seem to repeat it. I had an EV window open with #clipboard: on it, and was using it for some text, and then switched to doing other work that involved copying some URLs. When I tried searching for something else in a different EV window it wasn't responding. I happened to notice the other EV window, the one with #clipboard in it, and using an 'Everything' filter, had a ton of results in it and they looked to be from one of the web URLs I'd clipped before.

I know there are some situations where the Windows file dialog will take a URL as a 'filename' and download it. I'm wondering it that happened here?

Though now when I try to repeat it I can't get the same thing to happen.
Post Reply