I am doing something like this in my F5 command (execute):

C:\Python27\pythonw.exe G:\my_python_script.py

I want to run this script everytime I save the file. When I save this command as Ctrl + S, Notepad++ does not run it, only saves my file.

  • So, instead of pressing [Ctrl]+[S], then [F5] and [Enter], you just want to press [Ctrl]+[S] to save and run? – iglvzx Feb 16 '12 at 20:24
  • Yes. (characters_needed_to_send) – SuitUp Feb 16 '12 at 20:33

If you use the NppExec plugin, the following macro will do what you want:

C:\Python27\pythonw.exe G:\my_python_script.py

This can be bound to any key combination, does not rely on any existing shortcuts, and will bring up a save dialog if necessary.

| improve this answer | |
  • took some fiddling on my part, but indeed, this is a good solution. – el2iot2 Aug 20 '12 at 23:44

You can save a macro that will do this.

First, change the file so you can save. Then Start Macro, Ctrl+S, Execute your script, Stop Recording, Save recorded Macro.

Now you can either save this macro as Ctrl+S plus something, or just Ctrl+S, the latter would require you to un-map Ctrl+S.

If you must have it as a global hook into Ctrl+S (as Save) I do not have an answer for you, as I do not believe this is allowed, though you can macro any combination of events you want.

Hope this helps!

| improve this answer | |
  • Oh, I need to have 15 reputation to vote up you. :( – SuitUp Feb 16 '12 at 20:31
  • 1
    It does not work, how should i execute script so it will be recorded? – SuitUp Feb 16 '12 at 20:40
  • I believe you can give it a shortcut and then run that shortcut, in this case I was using a Python Script Plugin found here: npppythonscript.sourceforge.net – jidar Feb 16 '12 at 20:52

You can use AutoHotkey to easily create macros. For your case, the following script will work:

#IfWinActive, ahk_class Notepad++
^s:: ;Ctrl+S
    Send, ^s{F5}
    WinWaitActive, Run...
    Send, {Enter}

You may need to run the script as an administrator, since Notepad++ uses its own keyboard hooks.

Download: http://ahk.igalvez.net/Notepad++SaveRun.exe, 784KB

| improve this answer | |
  • Note that the recommended site to download AutoHotKey from is ahkscript.org so the donwload from ahk.igalvez.net seems to be from iglvzx's own domain which doesn't currently resolve (so the download doesn't even work). AutoHotkey is an excellent option to have a solution with, but rather than share a script, iglvzx seems to have preferred providing a custom installer. – TOOGAM Nov 19 '15 at 18:27
  • The script is there in the answer - you can compile it yourself. I think he added the exe link for folks not using autohotkey. – bgmCoder Aug 23 '17 at 22:56

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.