Access NPP command-line from plugin
-
I want my plugin to handle a custom command line parameter.
I can use the undocumented -z parameter that @Ekopalypse kindly nudged me toward.
For -multiInst I can get the NPP command line from Win32 API (GetCommandLineW), but for mono-instances that will only work for the initial launch.
It seems that mono-instance works on subsequent launches by sending the command line parameters to the first NPP instance via WM_COPYDATA message.
Unfortunately WM_COPYDATA doesn’t appear to be forwarded to plugins “messageProc” by _pluginsManager.relayNppMessages().
Worse - currently NPP strips out the -z (+ next) parameter and doesn’t add them to the WM_COPYDATA message, so it’s not even worth hooking it directly.
I think the best solution might be to implement a new NPPN Notfication something like NPPN_PARAMETERS_CHANGED?
Is this worth my while investigating and maybe raising a pull request?
Or is there a better way!?
Cheers.
-
sorry, but I don’t understand how you can start multiple mono-instances?
What did I miss? -
Apologies - I was trying to describe how NPP implements mono-instance mode…
Example…- Enable ‘mono-instance’ mode & close all NPP instances
- Launch NPP
notepad++.exe xyz.txt- Process ID = 123
- GetCommandLineW correctly shows
notepad++.exe xyz.txt
- Launch 2nd NPP instance
notepad++.exe -z -test abc.txt- Process ID = 234
- NPP 234 detects Mutex from NPP 123
- sends WM_COPYDATA to NPP 123 containing ‘abc.txt’
- kills self (234)
- NPP 123 receives WM_COPYDATA
- Opens ‘abc.txt’ alongside ‘xyz.txt’
- GetCommandLineW still just shows
notepad++.exe xyz.txt
How can I get the “-z -test” parameters from the plugin running in the mono-instanced NPP 123?
-
yes I see, I guess some kind of notification, as you wrote, is needed here.
The wording NPPN_PARAMETERS_CHANGED might be a bit misleading
as the mono-instance is still reporting its parameters correctly.
Maybe NPPN_DIFFERENT_INSTANCE_MERGED?
Native speakers - what do you suggest? :-)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login