Plugin macro copy paste
-
Hello,
I didn’t find this question answered elsewhere so here I go.
I’m trying to extract the navigation path of the structure of and XML file. So I want a descending list with each and every row’s XML address. I’m using the built in XML plugin to do this with the shortcut Shift+Ctrl+Alt+P. But it isn’t actually doing anything.My current recorded macro sequence when I start with the cursor on the second row of the file, with a second empty file open in a different tab:
Shift+Ctrl+Alt+P
Enter
DwnArrow
Ctrl+Pgdown
Ctrl+V
Enter
Ctrl+PgdownAny help is appreciated!
-
Because plugin commands change their command ID when plugins are removed or installed, the Macro recorder system does not record plugin commands.
However, if you’re confident that you won’t be adding or removing plugins for a while, you can work around this.
- Record and save the macro as normal. Close/Exit Notepad++ and restart.
- Find out what the current command ID for the macro command is.
- You can do this using the plugin NppUISpy. For example, in my current state, mine is
22148
:
- You can do this using the plugin NppUISpy. For example, in my current state, mine is
- Edit
%AppData%\Notepad++\shortcuts.xml
following guidelines in “Editing Configuration Files”- You’ve already restarted NPP
- Open
%AppData%\Notepad++\shortcuts.xml
- At the top of your macro, add the line
Where the<Action type="2" message="0" wParam="22148" lParam="0" sParam="" />
22148
in the wParam value is whatever command ID is currently assigned to “Current XML Path With Predicates” - Save
- Exit Notepad++ completely and restart
- Your macro should now include the XMLTools action
- Remember: if you install or remove a plugin, you will likely have to edit that wParam value
Example: I created a macro that I called
RunPluginAction
, that just consists of that 22148 command<Macro name="RunPluginAction" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="2" message="0" wParam="22148" lParam="0" sParam="" /> </Macro>
… When I run that macro while selecting that macro from shortcuts.xml, I get a popup:
… which tells me that the XML Tools action is running via the macro.It should work similarly for you, given a correct menu command ID.
-
@PeterJones
Wow it worked flawlessly! I’m just getting in to the space and I’m continuously flabergasted by how powerful a tool NPP can be. It’s exciting really! Thanks for your help, I’m sure that probably existed somewhere but I couldn’t find it with my search criteria…
I’ll be saving this as a bookmark for sure!Thanks!