I have a batchscript with the following contents:

python.exe c:/path/to/my/pythonscript/script.py %1

which I currently use to be able to drag-n-drop a file onto it. script.py then makes a duplicate of the file and processes it with some algorithm. Afterwards, it returns the path to the processed file on the commandline.

Now, what I want to achieve in N++ is: I want an icon in N++ on the toolbar -> When clicking this icon, I want to call the batchscript passing the filename/filepath of the currently opened file to it (which will effectively call python.exe c:/path/to/my/pythonscript/script.py FILEPATH_OF_OPENED_FILE_IN_NPP) and after the script is done, I'd like to automatically open the processed duplicate in N++.

I want to do it without using any sort of plugin. Is that possible?

I know it would be easily possible using some Plugins, e.g. using NppPythonScript, writing a script which calls the batchfile (using os.system("blaa.bat")) and then opening the resulting file using editor.open('...').

Is there a way without a plugin? Or maybe by writing a minimal plugin myself in C++ (as I'm not allowed to install any plugin from "inofficial" sources).



No, you'd have to write a plugin. All it needs is to add an icon to the toolbar which, when clicked, calls a function performing the tasks you want. You can actually write the plugin in several languages such as Python, C#, Ada, etc. Here's some guides to writing a Notepad++ plugin:

Update: I couldn't any examples of plugins in Python, however, it should be possible because they have demos of plugins written in odd languages such as Delphi and Ada. I pulled these links from the fourth link up above.

  • 2
    Oh, didn't know I could write a Plugin in Python itself. Ill check it out, thanks as of now. I hope it'll not be hard ;-) – tim Jun 10 '16 at 3:30
  • 1
    Thanks for the update - I was just about to ask, because I could not find any example myself either for a simple Python plugin. – tim Jun 10 '16 at 16:11
  • Your welcome. You'd find it hard to write the plugin itself in Python(plugins are DLLs), but the very first link I provided shows how to write a plugin that runs a Python(or, for that matter, any) script. Since they were able to write plugins directly in Ada/Delphi, you should be able to write one in Python, however that would be advanced stuff, and probably outside the scope of your question. – Anonymous Jun 10 '16 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.