Extend browser shortcut to search selected text in file contents

General discussion related to "Everything".
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Extend browser shortcut to search selected text in file contents

Post by Native2904 »

Hi,
Is it possible to modify the browser shortcut for searching selected text:

Code: Select all

javascript:location.href='es:'+document.getSelection();void(0);
so that it performs a content search within files?
So, if someone posts a config entry, I’d like to use it directly to search within my files (including file contents).
I reviewed the output of es.exe -help, but it doesn’t seem to provide the information I’m looking for.

Thanks in advance
therube
Posts: 5711
Joined: Thu Sep 03, 2009 6:48 pm

Re: Extend browser shortcut to search selected text in file contents

Post by therube »

(I'll just point out that browser javascript might point out some related topics.

I suppose you can do something with content: but that's kind of beyond me.)
void
Developer
Posts: 19830
Joined: Fri Oct 16, 2009 11:31 pm

Re: Extend browser shortcut to search selected text in file contents

Post by void »

Please try the following location:

javascript:location.href='es:content:<'+document.getSelection()+'>';void(0);


es: has nothing to do with the command line interface ES
Basically, the search box is set to anything after es:

ES: URL Protocol
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

Basically, the search box is set to anything after es:
I tried to combine this with another search filter

Code: Select all

javascript:location.href='es:addcol:A   A-label:="Content Count"   A:=STRINGCOUNT($content:,search:) content:<'+document.getSelection()+'>';void(0);
and it works. :D

Thanks!

An additional question:

Is the search term used in Everything available as a variable that can be passed to another program (e.g. an editor)?

For example, after running a search, I’d like to open a result in Notepad and have the search term automatically highlighted.
void
Developer
Posts: 19830
Joined: Fri Oct 16, 2009 11:31 pm

Re: Extend browser shortcut to search selected text in file contents

Post by void »

You'll need to setup a custom open command.
Custom open commands can specify the search with $search:
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

Thanks a lot for your help :!:

I think what I want to do might be a bit too much. When I search for a word in my files using Everything’s search box, I get a string like this in the searchbox:

Code: Select all

addcol:A A-label:="Content Count" A:=STRINGCOUNT($content:,search:) content:<[Shortcuts]>
That’s how Everything works and what i want.. but if I try to open AkelPad with the command:

Code: Select all

C:\tcmd\plugins\wlx\TCAkelPad\AkelPad64\AkelPad.exe "%1" "$search:"
then the entire search string is passed, but what I actually want is to search only for the word after content:<[Shortcuts]>.
void
Developer
Posts: 19830
Joined: Fri Oct 16, 2009 11:31 pm

Re: Extend browser shortcut to search selected text in file contents

Post by void »

Please try the following command:

Code: Select all

C:\tcmd\plugins\wlx\TCAkelPad\AkelPad64\AkelPad.exe "%1" "<REGEXREPLACE:<REGEXEXTRACT:$search:,"content:(\x22([^\x22]*)\x22|\S+)">,"\x22","">"
\x22 = "
REGEXREPLACE
REGEXEXTRACT
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

2Void

At first, I asked GitHub AI to translate the string above for me — when I read something with REGEX, I flinched like an elephant at a mouse. :lol:

Thank you very much!

But it wasn’t what I expected… so I asked for support on the AkelPad forum.

How can I pass a search term to AkelPad?
horst.epp
Posts: 1642
Joined: Fri Apr 04, 2014 3:24 pm

Re: Extend browser shortcut to search selected text in file contents

Post by horst.epp »

2Native2904
reading the actual help (2026) for AkelPad there is no simple command line switch
to add a search string.
I guess you only can do it with an AklePad script which can read all parameters.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

2Horst.Epp

Yes, i read it yesterday too and the nearest command what i found was /4158..
I guess you only can do it with an AklePad script which can read all parameters.
than i must ask a person like you >> if you can do this..I'm not so good in such things.. because I'm a mining maintenance technician and I’d have to spend hours reading up on it just to manage something like that.
:?
horst.epp
Posts: 1642
Joined: Fri Apr 04, 2014 3:24 pm

Re: Extend browser shortcut to search selected text in file contents

Post by horst.epp »

2Native2904
I only use AkelPad and its TC lister plugin to show or edit XYplorer scripts.
My normal editor is PSPad which supports a command line parameter for a string search at start-up.
So I will not spend time for such an AkelPad script.
The following article looks promising
https://qa.mythicsoft.com/15398/adding- ... ng-akelpad

From this article a working example example.
Tthis cmd line opens AkelPad and positions the cursor to line 4
C:\Tools\AkelPad\AkelPad.exe "Test.txt" /Call('Scripts::Main', 1, 'EvalCmd.js', `AkelPad.SendMessage(AkelPad.GetMainWnd(), 1204 /*AKD_GOTO*/, 0x1 /*GT_LINE*/, '4):1');`)
Last edited by horst.epp on Sat Mar 21, 2026 12:03 pm, edited 1 time in total.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

2Horst.Epp
There is no need to do that, if Pspsd can do this i would like to use them... in past I have used them a long time but I didn't know that he can do that!

Maybe the Lister can do that too
horst.epp
Posts: 1642
Joined: Fri Apr 04, 2014 3:24 pm

Re: Extend browser shortcut to search selected text in file contents

Post by horst.epp »

2Native2904
From the PSPad help for command line parameters

Code: Select all

 /F "search string" or -F "search string"
After start PSpad will run search on active file

 /FR "regular expression" or -FR "regular expression"
After start PSpad will run regular expression search on active file
Currently, I'm using PSPad version 5.5.2 (833) from 14/01/2026
horst.epp
Posts: 1642
Joined: Fri Apr 04, 2014 3:24 pm

Re: Extend browser shortcut to search selected text in file contents

Post by horst.epp »

This PSPad command line works for example
C:\Tools\PSPad\PSPad.exe "Test.txt" -F mystring
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

I really don't know how to thank you for all your trouble...

I’m not an expert on this, but I can offer a rough explanation in plain language:

Should this string =>

Code: Select all

C:\Users\Home\Apps\PSPad\PSPad.exe "%1" -F "<REGEXREPLACE:<REGEXEXTRACT:$search:,"content:(\x22([^\x22]*)\x22|\S+)">,"\x22","">"
not (?) trigger ...
  1. Open PSPad.exe
  2. with {"%1"} selected file
  3. {<REGEXREPLACE:<REGEXEXTRACT:$search:,"content:(\x22([^\x22]*)\x22|\S+)">,"\x22","">"}
    calculate the name after 'content' and remove quotes


....and should Point 3 not be finished, before Point 1 started?

I thought that, because if I trigger the task this way:

Code: Select all

C:\Users\Home\Apps\PSPad\PSPad.exe "%1" -F "Dummy_word"
than the PSPad opens the File with the "Dummy_word" matched.

---------------------------
I figured out from the forum how the command needs to be structured in order to pass a search query.

To open the AkelPadHelp with the marked string: <h3>Command line parameters</h3>
i have to enter:

Code: Select all

C:\tcmd\plugins\wlx\TCAkelPad\AkelPad64\AkelPad.exe "%1" /x "/Call('Scripts::Main', 7, `AkelPad.TextFind(0, '<h3>Command line parameters</h3>', 0x00200001)`)"
My workaround:
  1. Hit the Button ->

    Code: Select all

    javascript:location.href='es:content:<'+document.getSelection()+'>';void(0);
  2. Everything opens with the result - in the search bar stay something like:

    Code: Select all

    content:<C:\tcmd\plugins\wlx\>
  3. right click on a searchresult with this command:

    Code: Select all

     C:\tcmd\plugins\wlx\TCAkelPad\AkelPad64\AkelPad.exe "%1" /x "/Call('Scripts::Main', 7, `AkelPad.TextFind(0, '<REGEXREPLACE:<REGEXEXTRACT:$search:,"content:(\x22([^\x22]*)\x22|\S+)">,"\x22","">', 0x00200001)`)" 
  4. Akelpad opens with the right file but not matched the searched term
I think what I’m trying to achieve just isn’t practical to implement.
I don’t want to keep testing your patience any longer.
void
Developer
Posts: 19830
Joined: Fri Oct 16, 2009 11:31 pm

Re: Extend browser shortcut to search selected text in file contents

Post by void »

Please check what Everything is launching in the debug console:
  • In Everything, from the Tools menu, under the Debug submenu, check Console.
  • Setup your content search and open a file.
  • Check the console for the following lines:
    exec: shellexecute


To hide the debug console:
  • In Everything, from the Tools menu, under the Debug submenu, uncheck Console.


Please try a simpler command:

Code: Select all

C:\Users\Home\Apps\PSPad\PSPad.exe "%1" -F "<REGEXEXTRACT:$search:,"content:(\S+)">"
Avoid using quotes with your content: search, keep the search simple, eg:
*.txt content:Dummy_word


This should expand to:

C:\Users\Home\Apps\PSPad\PSPad.exe "c:\my example folder\selected file.txt" -F "Dummy_word"
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

Enter:

Code: Select all

C:\Users\Home\Apps\PSPad\PSPad.exe "%1" -F "<REGEXEXTRACT:$search:,"content:(\S+)">"
Everything searchbar:

Code: Select all

addcol:A A-label:="Content Count" A:=STRINGCOUNT($content:,viewers.bar) content:<viewers.bar>
output in the Console:

Code: Select all

exec: shellexecute file:C:\Users\Home\Apps\PSPad\PSPad.exe param:"C:\tcmd\usercmd.ini" -F ",viewers.bar)"
Parameters '"C:\tcmd\usercmd.ini" -F ",viewers.bar)"'
Directory 'C:\Users\Home\Apps\PSPad'
File 'C:\Users\Home\Apps\PSPad\PSPad.exe'
Mask 00000100
Enter ShellExecute
ShellExecute OK
The file opens without highlighting the search term.
void
Developer
Posts: 19830
Joined: Fri Oct 16, 2009 11:31 pm

Re: Extend browser shortcut to search selected text in file contents

Post by void »

Easiest way to get this to work:

Please try the following command:

Code: Select all

C:\Users\Home\Apps\PSPad\PSPad.exe "%1" -F "<REGEXEXTRACT:$search:,"(^|\s)content:(\S+)">"
Search for:

Code: Select all

addcol:A A-label:="Content Count" A:=STRINGCOUNT($content:,viewers.bar) content:viewers.bar
(remove the < and > from the content search)
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Using Everything search query to highlight text in editor

Post by Native2904 »

After a mix of help, tips, the debug console, the command line… and a few questionable late-night dreams, I finally figured out how to open files from Everything’s content search directly in an editor — jumping straight to the matched text and highlighting it. :D

So far, I’ve managed to get this working with two editors: AkelPad & PSPad

Background story:

Say a user posts a guide showing which file needs editing and exactly where. You highlight that spot in your browser… hit the bookmark…

Code: Select all

javascript:location.href='es:addcol:A A-label:="Content Count" A:=STRINGCOUNT($content:,"'+document.getSelection()+'") content:<'+document.getSelection()+'>';void(0);  
Everything pops up, lists all files with matches, and even shows how many hits each file has (just make sure not to include trailing spaces in your selection|that messes up your count).

A right-click on a match runs the command, opens the file in your editor, and jumps straight to the searched term.
To make this work, you need to create a custom open command in Everything.

For Akelpad:

Code: Select all

AkelPad.exe /x "%1" "/Call('Scripts::Main', 7, `AkelPad.TextFind(0, '<REGEXEXTRACT:$search:,"content:<([^>]+)>">', 0x00200001)`)"
For PSPad:

Code: Select all

PSPad.exe "%1" -F "<REGEXEXTRACT:$search:,"content:<([^>]+)>">"
Example:
https://imgur.com/CNn2CYb
Last edited by Native2904 on Wed Mar 25, 2026 7:24 pm, edited 2 times in total.
horst.epp
Posts: 1642
Joined: Fri Apr 04, 2014 3:24 pm

Re: Extend browser shortcut to search selected text in file contents

Post by horst.epp »

Glad that you finally solved it.
But how show the Custom command be shown or run with a right click on the result?
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

horst.epp wrote: Wed Mar 25, 2026 5:10 pm Glad that you finally solved it.
But how show the Custom command be shown or run with a right click on the result?
Please apply the following settings:
  • Everything Tools
  • Options…
  • Advanced
  • Show settings containing: custom_open_commands
  • Edit...
  • Add item...
  • Name: Your Choice
  • Command: YourPath2/AkelPad.exe /x "%1" "/Call('Scripts::Main', 7, AkelPad.TextFind(0, '<REGEXEXTRACT:$search:,"content:<([^>]+)>">', 0x00200001))"
  • Ok
  • OK
  • Apply
horst.epp
Posts: 1642
Joined: Fri Apr 04, 2014 3:24 pm

Re: Extend browser shortcut to search selected text in file contents

Post by horst.epp »

Native2904 wrote: Wed Mar 25, 2026 5:38 pm
horst.epp wrote: Wed Mar 25, 2026 5:10 pm Glad that you finally solved it.
But how show the Custom command be shown or run with a right click on the result?
Please apply the following settings:
Thanks, but I don't have problems to make Custom commands.
The question was how to show them on a right click from a result?
I can do that for certain file types using named "Custom_open_commands" definitions.
But this is not applicable here.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

2Horst.Epp
I suspected that you couldn’t have meant that… but why you should have a different context menu than I do — that I can’t make up.

But we talk about this here?
2026-03-25_194438.png
2026-03-25_194438.png (74.41 KiB) Viewed 11180 times
horst.epp
Posts: 1642
Joined: Fri Apr 04, 2014 3:24 pm

Re: Extend browser shortcut to search selected text in file contents

Post by horst.epp »

Native2904 wrote: Wed Mar 25, 2026 6:39 pm 2Horst.Epp
I suspected that you couldn’t have meant that… but why you should have a different context menu than I do — that I can’t make up.
You are right, I can just add it to my other named entries.

Btw. it makes sense to limit the file types for which the context menu entry is shown
Screenshot - 25.03.2026 , 21_57_49.png
Screenshot - 25.03.2026 , 21_57_49.png (10.63 KiB) Viewed 11143 times
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

horst.epp wrote: Wed Mar 25, 2026 6:52 pm Btw. it makes sense to limit the file types for which the context menu entry is shown
I didn’t realise that specifying file extensions changes the context menu behavior.
I’ll keep that in mind.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Using Everything search query to highlight text in editor

Post by Native2904 »

Addidtion:

In Notepad++, passing search queries is possible, but it requires a Python script.

Code: Select all

Notepad++.exe "%1" -pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,"content:<([^>]+)>">"
With EmEditor:

Code: Select all

EmEditor.exe /ff "<REGEXEXTRACT:$search:,"content:<([^>]+)>">"
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

If a *.pdf contains the content you need, PDFXEdit can handle it.

Code: Select all

PDFXEdit.exe /A "search=<REGEXREPLACE:<REGEXEXTRACT:$search:,"content:(\x22([^\x22]*)\x22|\S+)">,"\x22","">" "%1" 
Attachments
2026-03-28_162142.png
2026-03-28_162142.png (16.13 KiB) Viewed 10972 times
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Extend browser shortcut to search selected text in file contents

Post by tuska »

2Native2904

Hi,

I can open the file I'm searching for in Everything using the context menu entry “Highlight term in EmEditor”
but the file content I'm searching for isn't highlighted in EmEditor.

Code: Select all

Highlight term in EmEditor - find content:word inside file - ✅ include_files - *.ahk;*.eml;*.ini;*.txt;*.py;*.ion -
C:\Users\user\AppData\Local\Programs\EmEditor\EmEditor.exe "%1" /ff "<REGEXEXTRACT:$search:,"content:<([^>]+)>">"
____________________________________________________________________
Everything 1.5.0.1407a (x64) | EmEditor Professional (64-bit) - Version 26.0.901
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

Hi tuska,

Have you wrapped the search term in the Everything search bar with (angle brackets) <term> after triggering the bookmark?

If you open a new tab, type /console, and execute it, then repeat your search, right-click and pass it to EmEditor, you should see something like this in the console (look for exec: shellexecute):

Code: Select all

exec: command C:\Users\Home\Apps\EmEditor\EmEditor.exe "%1" /ff "<REGEXEXTRACT:$search:,"content:<([^>]+)>">"

exec: fullfilename C:\tcmd\Scripte\Everything2Tc\EV2TC.ini

exec: C:\Users\Home\Apps\EmEditor\EmEditor.exe "C:\tcmd\Scripte\Everything2Tc\EV2TC.ini" /ff "C:\tcmd\TOTALCMD64.EXE"

exec: shellexecute file:C:\Users\Home\Apps\EmEditor\EmEditor.exe param:"C:\tcmd\Scripte\Everything2Tc\EV2TC.ini" /ff "C:\tcmd\TOTALCMD64.EXE"

Parameters '"C:\tcmd\Scripte\Everything2Tc\EV2TC.ini" /ff "C:\tcmd\TOTALCMD64.EXE"'
Is there actually a value between the quotes after /ff?
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Extend browser shortcut to search selected text in file contents

Post by tuska »

Native2904 wrote: Sun Mar 29, 2026 7:00 am Hi tuska,

Have you wrapped the search term in the Everything search bar
with (angle brackets) <term> after triggering the bookmark?
2Native2904

Thanks for the tip!
I did NOT use the angle brackets.

Now it works great for me too.   :)

Example:
- Search in Everything:
ext:txt content:<08.12.2015>

- Right-click on the text file found, then click the context menu option “Highlight term in EmEditor”
- ... opens EmEditor and highlights the text “08.12.2015” (without quotation marks!) in EmEditor.

Thanks again!
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Extend browser shortcut to search selected text in file contents

Post by tuska »

I have the following bookmark:

Search > Custom:

Code: Select all

content:mytext: | ansicontent:mytext: | ifilter-content:mytext: | plain-text-content:mytext: | unicodecontent:mytext: | utf8content:mytext: | utf16content:mytext: | utf16becontent:mytext:
Macro:

Code: Select all

mc<mytext>
How should I adjust this search ->
ext:txt content:<08.12.2015>
(... search term highlighted in EmEditor because of the angle brackets < >)
so that I can enter the following as a search term with a bookmark macro? ->
ext:txt mc:08.12.2015
:?:

After selecting the “Highlight term in EmEditor” entry from the context menu, the search term should be highlighted in EmEditor.
I've already tried, unfortunately without success so far...

EDIT:
I forgot to adjust the 'custom_open_commands' setting -> the Everything macro is set to “mc”.
My final solution can be found here: ... and below ...
C:\Users\user\AppData\Local\Programs\EmEditor\EmEditor.exe "%1" /ff <REGEXEXTRACT:$search:,"mc:(.+)">
Last edited by tuska on Mon Mar 30, 2026 12:30 pm, edited 1 time in total.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

Ok, i believe I understand what you want to archive..

try this please:

Code: Select all

EmEditor.exe "%1" /ff <REGEXEXTRACT:$search:,"content:(.+)">
that way, you don't need any angle brackets.
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Extend browser shortcut to search selected text in file contents

Post by tuska »

Native2904 wrote: Sun Mar 29, 2026 3:16 pm try this please:

Code: Select all

EmEditor.exe "%1" /ff <REGEXEXTRACT:$search:,"content:(.+)">
that way, you don't need any angle brackets.
Thank you!
⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺
This code works WITHOUT angle brackets < > in the manual search query and with the context menu entry! (custom_open_commands)

Code: Select all

C:\Users\user\AppData\Local\Programs\EmEditor\EmEditor.exe "%1" /ff <REGEXEXTRACT:$search:,"content:(.+)">
In EmEditor, the found text is highlighted.
Example:
ext:txt content:08.12.2015

⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺
This code works WITHOUT angle brackets < > in the search query WITH bookmark "mc" and with the context menu entry! (custom_open_commands)

Code: Select all

C:\Users\user\AppData\Local\Programs\EmEditor\EmEditor.exe "%1" /ff <REGEXEXTRACT:$search:,"mc:(.+)">
In EmEditor, the found text is highlighted.
Example:
ext:txt mc:08.12.2015


____________________
user == your-user-name
Everything 1.5.0.1407a (x64)

_____________________________________________________________________________
Menu "Tools" -> "Options..." -> "Advanced" -> "custom_open_commands" -> "Edit..." ->

Code: Select all

name:        Highlight term in EmEditor
description: find content:word inside file
...........: ✅ include_files
filter:      *.ahk;*.bar;*.bas;*.csv;*.eml;*.inc;*.ini;*.ion;*.js;*.log;*.md;*.mnu;*.nfo;*.odt;*.py;*.txt
command:     C:\Users\user\AppData\Local\Programs\EmEditor\EmEditor.exe "%1" /ff <REGEXEXTRACT:$search:,"content:(.+)">
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Using Everything search query to highlight text in editor

Post by tuska »

Native2904 wrote: Sat Mar 28, 2026 7:57 am Addidtion:
In Notepad++, passing search queries is possible, but it requires a Python script.

Code: Select all

Notepad++.exe "%1" -pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,"content:<([^>]+)>">"
2Native2904
I find highlighting searched text in text editors using context menu items in Everything to be a very helpful feature.

For this reason, I also tried setting this up for Notepad++ v8.9.1 (64-bit) using the
PythonScript - Version 2.1” plugin I installed for this purpose.

Although the .ini or .txt file opens in Notepad++, I was unfortunately unable to get the searched text to be highlighted.
Do you perhaps have any other ideas on how this could be implemented?

custom_open_commands - command:

Code: Select all

C:\totalcmd\Tools\Notepad++\notepad++.exe "%1" -pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,"content:(.+)">
- OR -

Code: Select all

C:\totalcmd\Tools\Notepad++\notepad++.exe "%1" -pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,"content:<([^>]+)>">"
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

Hello Tuska,

there is one downside: this requires a script, and the script is configured for a German interface.

You need to create two files in the folder:

Notepad++\plugins\PythonScript\scripts:

startup.py
commandlineSearch27472.py

The startup.py should contain the following:

Code: Select all

from Npp import *
import sys

console.write("Versuche Import...\n")

try:
    import commandlineSearch27472
    console.write("IMPORT OK\n")
except Exception as e:
    console.write("IMPORT FEHLER: " + str(e) + "\n")
and the commandlineSearch.py the following:

I am not the author of this script — I only modified it until it worked without errors for me.

Code: Select all

# -*- coding: utf-8 -*-
"""in response to https://community.notepad-plus-plus.org/topic/27472/
(fixed URL to Topic)

process -pluginMessage="PythonScriptCommandlineSearch=term"

`term` must be a normal search term, not a regular expression; it currently cannot include semicolons `;` or double-quotes `"`

updated version for German localization
"""
#####   -------
#####   Instructions:
#####
#####   {these assume a normal installation of Notepad++, using %AppData%\Notepad++ for user configuration}
#####
#####   See [PythonScript FAQ](https://community.notepad-plus-plus.org/topic/23039/faq-how-to-install-and-run-a-script-in-pythonscript)
#####
#####   - Create `%AppData%\Notepad++\plugins\PythonScript\scripts\commandlineSearch27472.py`, from the contents below
#####   - Check for menu entry **Plugins > Python Script > Scripts > startup (User)**
#####       - if it is listed, `Ctrl+click` on it to edit, and add the following to the end:
#####       - if it isn't listed, create `%AppData%\Notepad++\plugins\PythonScript\scripts\user.py` from the contents below
#####       - set **Plugins > Python Script > Configuration...** to **Initialisation: `ATSTARTUP`**
#####       - exit and restart Notepad++
#####
#####   After doing that, the script should look for
#####   `notepad++ -pluginMessage="PythonScriptCommandlineSearch=term"`, and run a search for `term`
#####
#####   For now, it won't work with semicolon `;` or double-quote `"` in the search term;
#####       if that is needed, I would need to add an escape sequence processing, which would make it more complicated.
#####   -------

from Npp import console
console.write(">>> commandlineSearch27472 geladen <<<\n")

from Npp import notepad, console, NOTIFICATION, MENUCOMMAND
import ctypes
import sys
import re
import time

import ctypes
from ctypes.wintypes import HWND, UINT, WPARAM, LPARAM, HMODULE, LPCWSTR, LPCSTR, LPVOID

def usePluginMessageString27472de(s):
    m = re.search(r'PythonScriptCommandlineSearch=([^;"]+)', s)
    
    # ✅ Prüfung hinzufügen
    if not m:
        console.write("FEHLER: Suchterm nicht gefunden in: '%s'\n" % s)
        return
    
    t = m.group(1)

    # Define the functions and constants needed
    FindWindow = ctypes.windll.user32.FindWindowW
    FindWindow.argtypes = [LPCWSTR, LPCWSTR]
    FindWindow.restype  = HWND

    FindWindowEx = ctypes.windll.user32.FindWindowExW
    FindWindowEx.argtypes = [HWND, HWND, LPCWSTR, LPCWSTR]
    FindWindowEx.restype  = HWND

    SendMessageStr = ctypes.windll.user32.SendMessageW
    SendMessageStr.argtypes = [HWND, UINT, WPARAM, LPCWSTR]
    SendMessageStr.restype  = LPARAM

    SendDlgItemMessage = ctypes.windll.user32.SendDlgItemMessageW
    SendDlgItemMessage.argtypes = [HWND, UINT, UINT, WPARAM, LPARAM]
    SendDlgItemMessage.restype = LPARAM

    WM_SETTEXT = 0x000C
    BM_CLICK = 0x00F5

    # see https://community.notepad-plus-plus.org/post/59785 for VB.net inspiration
    notepad.menuCommand(MENUCOMMAND.SEARCH_FIND)
    hFindWnd = None
    # try 10 times
    for i in range(10):
        hFindWnd = FindWindow("#32770", "Find")
        if not hFindWnd:
            hFindWnd = FindWindow("#32770", "Suchen")
        if not hFindWnd:
            hFindWnd = FindWindow("#32770", "Suchen und ersetzen")
        if hFindWnd:
            break
        time.sleep(0.2) # wait for the Find window to appear

    hComboBx = FindWindowEx(hFindWnd, 0, "ComboBox", None) if hFindWnd else 0
    hFindStr = FindWindowEx(hComboBx, 0, "Edit", None) if hComboBx else 0
    SendMessageStr(hFindStr, WM_SETTEXT, 0, t)
    time.sleep(0.1)

    # set search mode:
    hNormBtn = None
    for i in range(10):
        hNormBtn = FindWindowEx(hFindWnd, 0, "Button", "Norma&l")
        if hNormBtn:
            break
        time.sleep(0.2)
    if hNormBtn:
        SendMessageStr(hNormBtn, BM_CLICK, 0, None)
        time.sleep(0.1)

    # start search with Enter key using keyboard simulation
    console.write("Starte Suche nach: '%s'\n" % t)
    
    # Simulate Enter key press
    ctypes.windll.user32.keybd_event(0x0D, 0, 0, 0)  # VK_RETURN down
    time.sleep(0.05)
    ctypes.windll.user32.keybd_event(0x0D, 0, 2, 0)  # VK_RETURN up
    console.write("Enter-Taste simuliert\n")

    # TODO: I'd like to try SendDlgItemMessageW(hFindWnd, ctrlID, BM_CLICK, 0, 0), to avoid having to search for the "Find Next" button
    #   but using the 1625 from search macros, I couldn't get it to change Search Mode, so just manually click the buttons for now

def getStringFromNotification27472de(args):
    code = args['code'] if 'code' in args else None
    idFrom = args['idFrom'] if 'idFrom' in args else None
    hwndFrom = args['hwndFrom'] if 'hwndFrom' in args else None
    #console.write(f"notification(code:{code}, idFrom:{idFrom}, hwndFrom:{hwndFrom}) received\n")
    if idFrom is None: return
    s = ctypes.wstring_at(idFrom)
    #console.write(f"\tAdditional Info: str=\"{s}\"\n")
    usePluginMessageString27472de(s)

def getStringFromCommandLine27472de():
    for token in sys.argv:
        if len(token)>15 and token[0:15]=="-pluginMessage=":
            s = token[15:]
            #console.write(f"TODO: process {token} => \"{s}\"\n")
            usePluginMessageString27472de(s)

notepad.callback(getStringFromNotification27472de, [NOTIFICATION.CMDLINEPLUGINMSG])
console.write("Registered getStringFromNotification27472de callback for CMDLINEPLUGINMSG\n")
getStringFromCommandLine27472de()

You then need to set Plugins -> Python Script -> Configuration > "Initialization" to "ATSTARTUP" in Notepad++.

2026-03-31_171942.png
2026-03-31_171942.png (120.26 KiB) Viewed 10660 times
Once you have done that, it should work.
If it doesn’t… it took me “a bit” to get it working as well… please open the console under the Python configuration and post the output here.
Attachments
image.png
image.png (15.33 KiB) Viewed 10659 times
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Extend browser shortcut to search selected text in file contents

Post by tuska »

Hello Native2904,

Unfortunately, the search text still isn't highlighted.
Language “German” in Notepad++, Everything 1.5a.

You mention commandlineSearch27472.py in one place and commandlineSearch.py in another?

But we can leave it at that, because it works for me in EmEditor.
 
2026-03-31_Notepad Plus Plus - Python Script - Console.png
2026-03-31_Notepad Plus Plus - Python Script - Console.png (59.8 KiB) Viewed 10641 times
2026-03-31_custom_open_commands_Notepad Plus Plus & Context menu for Notepad in Everything.png
2026-03-31_custom_open_commands_Notepad Plus Plus & Context menu for Notepad in Everything.png (67.74 KiB) Viewed 10641 times
2026-03-31_PythonScript_scripts.png
2026-03-31_PythonScript_scripts.png (99.63 KiB) Viewed 10641 times
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

The error can’t be far off…

the console shows that the search is not being passed correctly… instead of searching for the term, it searches for:

‘PythonScriptCommandlineSearch=’

… instead of:

‘PythonScriptCommandlineSearch=term

maybe it’s because you saved it in UTF-8 with BOM… but I’m not entirely sure about that.
2026-03-31_214753.png
2026-03-31_214753.png (31.96 KiB) Viewed 10635 times
Last edited by Native2904 on Wed Apr 01, 2026 5:11 am, edited 1 time in total.
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Extend browser shortcut to search selected text in file contents

Post by tuska »

Hmm, I converted the files to UTF-8 — no difference.

I just noticed the following:

commandlineSearch27472.py - Line No.. 45:
m = re.search(r'PythonScriptCommandlineSearch=([^;"]+)', s)

custom_open_commands
-pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,"content:(.+)">
-pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,"content:<([^>]+)>">"

I modified the CODE as follows:
"... -pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,"content:([^;"]+)"
and was able to find the search term “Don” this way; in other words, the term was highlighted twice in Notepad++.

This is despite the fact that the following message appeared three times in the console:
"FEHLER: Suchterm nicht gefunden in: '"PythonScriptCommandlineSearch="Don'"

When trying to find “Don HO,” Notepad++ asks if you want to create a new file:
""C:\totalcmd\Tools\Notepad++\HO" existiert nicht. Soll die Datei erstellt werden?"

I therefore suspect that the search query needs to be redefined in this case.

PS:
"these assume a normal installation of Notepad++, using %AppData%\Notepad++ for user configuration"
My installation directory is C:\totalcmd\Tools\Notepad++\. Hopefully, this won't be the reason it fails.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

these assume a normal installation of Notepad++, using %AppData%\Notepad++ for user configuration"
My installation directory is C:\totalcmd\Tools\Notepad++\. Hopefully, this won't be the reason it fails.
No, I'm using Notepad++ as portable too.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...do you know that feeling when you can see there’s a mistake but can’t figure out where it is?

I noticed that in the key, unlike in the first two, there is an extra >"?
Maybe try if it works like this:

,"content:<([^>]+)">
IMG_0910.jpeg
IMG_0910.jpeg (59.14 KiB) Viewed 10582 times
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Extend browser shortcut to search selected text in file contents

Post by tuska »

Native2904 wrote: Wed Apr 01, 2026 5:09 am ...do you know that feeling when you can see there’s a mistake but can’t figure out where it is?
Yes, unfortunately all too often. :?
Native2904 wrote: Wed Apr 01, 2026 5:09 am Maybe try if it works like this:
,"content:<([^>]+)">
Unfortunately, that doesn't work for me either.

"FEHLER: Suchterm nicht gefunden in: 'PythonScriptCommandlineSearch='
; ERROR: Search term not found in: ‘PythonScriptCommandlineSearch=’
IMPORT OK"

I suggest we wait and see if anyone else might take on this issue.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

Hi,
i tested it a lot..

please try this:

content:\"([^\"]+)\">"
2026-04-01_175525.png
2026-04-01_175525.png (51.17 KiB) Viewed 10536 times
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Extend browser shortcut to search selected text in file contents

Post by tuska »

Native2904 wrote: Wed Apr 01, 2026 4:24 pm Hi,
i tested it a lot..

please try this:
Hi,
thanks for testing.
I'm wondering if that ever worked for you with EV and Notepad++?

Unfortunately, it didn't work for me again.

Code: Select all

"C:\totalcmd\Tools\Notepad++\Notepad++.exe" "%1" -pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,"content:\"([^\"]+)\">"
- OR -
"C:\totalcmd\Tools\Notepad++\Notepad++.exe" "%1" -pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,"content:\"([^\"]+)\"
- OR -
"C:\totalcmd\Tools\Notepad++\Notepad++.exe" "%1" -pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,content:\"([^\"]+)\">"
- OR - 
"C:\totalcmd\Tools\Notepad++\Notepad++.exe" "%1" -pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,content:\"([^\"]+)\"
FEHLER: Suchterm nicht gefunden in: 'PythonScriptCommandlineSearch='
IMPORT OK

Unfortunately, I no longer feel motivated to conduct further tests on the topic of “EV & Notepad++”.

No offense, but I probably won't get back into this topic until someone lets us know
that it worked for them and provides all the codes in detail.
______________________________________
I'd like to take this opportunity to thank you again for the code for “EV & EmEditor.”
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

I'd like to take this opportunity to thank you again for the code for “EV & EmEditor.”
Gladly.
Unfortunately, it didn't work for me again.
I am sorry that I could not be of help to you.
I'm wondering if that ever worked for you with EV and Notepad++?
It works — for whatever reason.

Select a word in the browser, find it in Everything content, open the file, and jump to the searched term or highlight all occurrences in Notepadd++.
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Extend browser shortcut to search selected text in file contents

Post by tuska »

Native2904 wrote: Wed Apr 01, 2026 5:12 pm It works — for whatever reason.
The file “license.txt” in the “Notepad++” directory contains the text “Don HO”.
Can you search for that in Everything as well and view it via the context menu marked in Notedpad++?
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

2026-04-01_200234.png
2026-04-01_200234.png (136.29 KiB) Viewed 10502 times
# # # # # # # # # # #

https://imgur.com/7jI3Y1i
tuska
Posts: 1378
Joined: Thu Jul 13, 2017 9:14 am

Re: Extend browser shortcut to search selected text in file contents

Post by tuska »

2Native2904
OK, thanks!

I tried to document my tests above (screenshot + code)
but I still haven't managed to get it to work.

That's it for me - I'm giving up on this.
I deleted the “PythonScript” (about 680 files).
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

I used my CMD, took the absolute path to Notepad++ and the file to open, and appended the string at the end
-pluginMessage="PythonScriptCommandlineSearch=myterm".
Then I kept testing in conjunction with the console until it finally worked.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

optimized version

Post by Native2904 »

*Update*

The commands were inconsistent when performing a manual content search via the address bar.
In the Everything search bar, a typical query looks like:
*****
a) content:my search
*****
However, when the search was triggered via the bookmark from Browser, the search field in Everything always contained something like:
*****
b) addcol A-label:="Content Count" A:=STRINGCOUNT($content:,"my search") content<my search>
*****
Because of this, the bookmark needs to be adjusted so that angle brackets are no longer used in the Everything search query (b).
This ensures that the commands for forwarding the search to text files also work correctly when performing a manual content search (a).

To find terms from the content search within indexed files using a context menu command in text files, the following commands need to be adjusted.

For PSPad:

Code: Select all

PSPad.exe "%1" -F "<REGEXEXTRACT:$search:,"(?<!\$)content:([^)]*)">
For Akelpad:

Code: Select all

AkelPad64\AkelPad.exe /x "%1" "/Call('Scripts::Main', 7, `AkelPad.TextFind(0, '<REGEXEXTRACT:$search:,"(?<!\$)content:(.+?)(?:\s+[a-z]+:|$)">', 0x00200001)`)"
For Notepad++ (only with an python script available)

Code: Select all

Notepad++.exe "%1" -pluginMessage="PythonScriptCommandlineSearch=<REGEXEXTRACT:$search:,"(?<!\$)content:(.+?)(?:\s+[a-z]+:|$)">"
For PDFXEdit (*.md;*.epub;*.pdf)

Code: Select all

PDFXEdit.exe /A "search=<REGEXREPLACE:<REGEXEXTRACT:$search:,"(?<!\$)content:(\x22([^\x22]*)\x22|[^)\s]+)">,"\x22","">" "%1" 
The bookmark used to search for selected text from the browser as content within local files must be configured as follows:

Code: Select all

javascript:location.href='es:addcol:A A-label:="Content Count" A:=STRINGCOUNT($content:,"'+document.getSelection()+'") content:'+document.getSelection()+'';void(0);  
Last edited by Native2904 on Mon Apr 13, 2026 3:29 am, edited 1 time in total.
horst.epp
Posts: 1642
Joined: Fri Apr 04, 2014 3:24 pm

Re: Extend browser shortcut to search selected text in file contents

Post by horst.epp »

2Native2904
The updated version of PSPad content search doesn't work :(
PSPad does not find the string after start-up.

This older version is fine.
PSPad.exe "%1" -F "<REGEXEXTRACT:$search:,"content:<([^>]+)>">"

I start it with a bookmark from browser.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: Extend browser shortcut to search selected text in file contents

Post by Native2904 »

But we are talking about the case where the search term in Everything’s search bar is no longer enclosed in square brackets?
Post Reply