shortcuts.xml <Action> tag
-
I was unable to find any documentation on editing macros. While the <Macro> tag has pretty self explanatory parameters, I have no idea what most of the parameters in <Action> do. Is there some documentation on these? Or someone who knows what each of them do and what values are accepted.
“type” seems to define if the action is a character input and “sParam” is the character to input. However, I have no idea what “message”, “wParam” and “lParam” do.
-
@SusiKette said in shortcuts.xml <Action> tag:
I was unable to find any documentation on editing macros.
Where did you look? The official docs at npp-user-manual.org gave a section on the macros in shortcuts.xml, which explains each of those attributes and where to find values
-
I was expecting the information to be at “Task automation with macros”, or at the very least have a link to information on how to edit macros. Finding this document, it seems some messages return values, can Notepad++ use them? In other words, can you make conditional macros? Also, some messages take arguments. How do I know whether sParam, wParam or lParam is used for which argument, or is there another way of using them?
-
@SusiKette said in shortcuts.xml <Action> tag:
I was expecting the information to be at “Task automation with macros”, or at the very least have a link to information on how to edit macros.
You mean like the last sentence on that page, where it says:
Finding this document, it seems some messages return values, can Notepad++ use them?
It cannot use messages that return values in Macros.
In other words, can you make conditional macros?
Nope. There are no variables, loops, or conditionals in Macros. Macros are purely linear.
For anything more complicated than simple linear macros, you need to either write a plugin; or use one of the many scripting plugins, including PythonScript, NppExec, LuaScript, “jN Notepad++ Plugin” (javascript scripting); or use an external remote-control library, like my “PerlScript”
How do I know whether sParam, wParam or lParam is used for which argument, or is there another way of using them?
For Scintilla messages, you look at the Scintilla.iface you already linked, or the Scintilla documentation. For Notepad++ messages, you look at the Notepad++ Plugin Communication doc.
-
@SusiKette said in shortcuts.xml <Action> tag:
sParam, wParam or lParam
In case I didn’t make a couple of things clear enough:
- As the Config Files Details: Macros sectinon says,
sParam
is just used for Macros; really, the value insParam
is passed to the second (lParam
) slot in the actual SendMessage that is run behind the scenes. SosParam
is just used for any Notepad++ type=3 message (search/replace syntax) or Scintilla type=1 message that uses a string for the second SendMessage variable. - In the Scintilla.iface that you linked, the
StartStyling=2032(position start, int unused)
examples show the CamelCase version of theSCI_
Message name, followed by the message ID, and thewParam
andlParam
variables; any of the variables that it leaves blank are meant to indicate that the particular slot is not used, so should be set to 0: thus,blah=###(x,)
means you setlParam
to 0 for theSCI_BLAH
message.
- As the Config Files Details: Macros sectinon says,
-
Hello,@SusiKette
Please try this code, To shortcuts.xml <Action> tag.In Windows 7|8|10 C:\Users%username%\AppData\Roaming\Notepad++\shortcuts.xml
Code:
<NotepadPlus> <InternalCommands /> <Macros> <Macro name="Trim Trailing and save" Ctrl="no" Alt="yes" Shift="yes" Key="83"> <Action type="2" message="0" wParam="42024" lParam="0" sParam="" /> <Action type="2" message="0" wParam="41006" lParam="0" sParam="" /> </Macro> <Macro name="abc" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="1" message="2170" wParam="0" lParam="0" sParam="a" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="b" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="c" /> </Macro> </Macros> <UserDefinedCommands>....
I hope this code will be useful to you.
Thank you.