PythonScript icon indicating copy to clipboard operation
PythonScript copied to clipboard

Autostart of py script

Open ComFreek opened this issue 10 years ago • 7 comments

What is the best way to make a script run upon every start of Notepad++?

I currently use the solution below:

# I added the following line in startup.py
exec(open("C:/Users/-----/AppData/Roaming/Notepad++/plugins/config/PythonScript/scripts/AutoTabSpace.py").read())

I don't consider it very elegant:

  1. It relies on a hard-coded path.
  2. It always loads from the user-wide set of scripts. Ideally, one would simply write loadScriptWithName(...) and a matching script would be dynamically loaded (either from the machine-wide or user-wide set of scripts).
  3. One must manually add a line to a file. It would be very nice if scripts could be shipped with configuration files.

Anyway, thanks for the great plugin! It really makes a difference if you don't have to worry about window events, handles or C strings :)


Edit I've just came across the note in the documentation (Plugin Installation and Usage / Startup). After having changed the initializing type to ATSTARTUP, my script still doesn't get run when Notepad++ starts (without the line in startup.py). It works however if I start it manually.

ComFreek avatar Jun 09 '14 15:06 ComFreek