Hi, I didn't find any solution with Npp (using 4.9.2) for inserting templates from text files into the current document at the current cursor position. I tried various plugins, I searched the forum, but no success.
That's why I made following:
1. I created a Run command, which copies the template file content to the windows's clipboard (using cliptext)
2. I created a Macro, which executes the item from Run menu, which I created above and after that which makes a SCI_PASTE command as following:
Shortcuts.xml:
<Macros>
<Macro name="Insert Addresses" Ctrl="no" Alt="no" Shift="no" Key="0">
<Action type="2" message="0" wParam="86537" lParam="0" sParam="" /> <!-- Call 2. item from Run menu -->
<Action type="0" message="2179" wParam="0" lParam="0" sParam="" /> <!-- SCI_PASTE -->
</Macro>
</Macros>
<UserDefinedCommands>
..
<Command name="Addresses" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /k cliptext from "$(NPP_DIRECTORY)\templates\Addresses.txt" && exit</Command>
</UserDefinedCommands> <!-- 2. item of Run menu -->
So far, so good.
But there are some problems and questions:
1. The Run command is executed via ::ShellExecute() and doesn't wait for end of execution. That's why the clipboard is not filled correctly, but the Paste command is already executed. As solution I patched the code with a ::Sleep() as dirty hack.
2. Using the ActionType 2 (mtMenuCommand) with wParam="86537" for executing the Run command number 2, I resolved the parameter value with the debugger only. Is there any description using the ActionTypes 2 and its parameters? How are counted the menu items?
3. How can I call a user defined Run command from a macro via a user defined shortcut (e.g. CTRL-SHIFT-0)? Unfortunately the macro recorder doesn't work in this context.
Does anybody know a better solution?
Thanks and sorry for my english.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I didn't find any solution with Npp (using 4.9.2) for inserting templates from text files into the current document at the current cursor position. I tried various plugins, I searched the forum, but no success.
That's why I made following:
1. I created a Run command, which copies the template file content to the windows's clipboard (using cliptext)
2. I created a Macro, which executes the item from Run menu, which I created above and after that which makes a SCI_PASTE command as following:
Shortcuts.xml:
<Macros>
<Macro name="Insert Addresses" Ctrl="no" Alt="no" Shift="no" Key="0">
<Action type="2" message="0" wParam="86537" lParam="0" sParam="" /> <!-- Call 2. item from Run menu -->
<Action type="0" message="2179" wParam="0" lParam="0" sParam="" /> <!-- SCI_PASTE -->
</Macro>
</Macros>
<UserDefinedCommands>
..
<Command name="Addresses" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /k cliptext from "$(NPP_DIRECTORY)\templates\Addresses.txt" && exit</Command>
</UserDefinedCommands> <!-- 2. item of Run menu -->
So far, so good.
But there are some problems and questions:
1. The Run command is executed via ::ShellExecute() and doesn't wait for end of execution. That's why the clipboard is not filled correctly, but the Paste command is already executed. As solution I patched the code with a ::Sleep() as dirty hack.
2. Using the ActionType 2 (mtMenuCommand) with wParam="86537" for executing the Run command number 2, I resolved the parameter value with the debugger only. Is there any description using the ActionTypes 2 and its parameters? How are counted the menu items?
3. How can I call a user defined Run command from a macro via a user defined shortcut (e.g. CTRL-SHIFT-0)? Unfortunately the macro recorder doesn't work in this context.
Does anybody know a better solution?
Thanks and sorry for my english.