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:
- Plugin to run python script example
- Plugin Development Quick-Start Guide
- Plugin How-To
- Plugin Development
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.