strange behavior with macro
-
``` <Macro name="purge" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="3" message="1700" wParam="0" lParam="0" sParam="" /> <Action type="3" message="1601" wParam="0" lParam="0" sParam="https.*?\.jpg" /> <Action type="3" message="1625" wParam="0" lParam="2" sParam="" /> <Action type="3" message="1702" wParam="0" lParam="768" sParam="" /> <Action type="3" message="1701" wParam="0" lParam="1615" sParam="" /> <Action type="0" message="2422" wParam="0" lParam="0" sParam="" /> <Action type="0" message="2325" wParam="0" lParam="0" sParam="" /> <Action type="2" message="0" wParam="41001" lParam="0" sParam="" /> <Action type="0" message="2179" wParam="0" lParam="0" sParam="" /> <Action type="2" message="0" wParam="42055" lParam="0" sParam="" /> <Action type="2" message="0" wParam="42079" lParam="0" sParam="" /> </Macro>```
i think the issue is when paste
copy marked text
into new file.
from the macro paste from clipboard (latest clipboard). instead if i run all the individual steps manually, paste on new file the text copied from the last clipboard, then the correct text -
I haven’t looked into it further yet, but one thing that comes to mind is that the Copy Marked Text button in the Mark window does NOT record an action into a macro. I believe a workaround is to use Search menu > Copy Styled Text > Find Mark Style .
But I’ll look closer into it in a bit and comment again…
-
Yea, I think that’s it; using the Search menu item I mentioned will insert this command into your macro before the
2422
item:<Action type="2" message="0" wParam="43061" lParam="0" sParam="" />
If you look up 43061 in menuCmdID.h, you find it as:
#define IDM_SEARCH_MARKEDTOCLIP (IDM_SEARCH + 61)
-
wow, great solution!
it work fine. thank you for this wonderful solution.All the best
-
@Alan-Kilborn said in strange behavior with macro:
<Action type=“2” message=“0” wParam=“43061” lParam=“0” sParam=“” />
Alan, I tried to find the Scintilla function corresponding to
IDM_SEARCH_MARKEDTOCLIP
. I could not find it.Could you please explain to me (and other interested readers) how to go from
wParam="43061"
via menuCmdID.h to a Scintilla function? -
@Paul-Wormer said in strange behavior with macro:
@Alan-Kilborn said in strange behavior with macro:
<Action type=“2” message=“0” wParam=“43061” lParam=“0” sParam=“” />
Alan, I tried to find the Scintilla function corresponding to
IDM_SEARCH_MARKEDTOCLIP
. I could not find it.The IDM-prefixed messages are Notepad++ menu command messages, not Scintilla messages.
Could you please explain to me (and other interested readers) how to go from
wParam="43061"
via menuCmdID.h to a Scintilla function?Assuming you said "please explain how to go from a Notepad++ menu command to the number found in menuCmdID.h to get to
wParam="43061"
:- menuCmdID.h shows
#define IDM_SEARCH_MARKEDTOCLIP (IDM_SEARCH + 61)
- Look for the first occurrence of IDM_SEARCH, which shows
#define IDM_SEARCH (IDM + 3000)
- The
#define
forIDM
near the top
#define IDM 40000
- So IDM_SEARCH = 40000 + 3000 = 43000, and thus IDM_SEARCH_MARKEDTOCLIP = 43000 + 61 = 43061.
The macros section of the user manual explains how to take that 43061 number and create the type2 (Notepad++) action by putting it into the wParam.
And reading a macro is just going in the reverse: look what type it is:
- if it’s type2, you will use the wParam to get a number, then you will have to decompose that number into groups – most groups are the ten-thousands-place at the top level, the thousands-place for which subgroup, and the hundreds-tens-ones for which command from that group. So if you’ve got 43061, you see that it’s 40000 = IDM, so look for that definition; then you look for the 3000 that uses that IDM prefix to find IDM_SEARCH, then look for the 61 that gets added to IDM_SEARCH to find the individual command.
- If it’s a type0 or type1, it will be a scintilla command, so use Scintilla.iface as the ID-to-Number document (noting that Scintilla.iface doesn’t show the SCI_ prefix, so if you wanted to look up
2001
, you would see it as AddText=2001, which corresponds to SCI_ADDTEXT message; similarly, SCI_GETTEXT would search (case-insensitive) for GETTEXT to find [GetText=2182] in the .iface document. - if it’s a type3, you need the searching actions as macros section to understand what’s going on.
—
edit: fixed 43016 to the correct 43061 – can I blame old-age-onset dyslexia? Thanks @Lycan-Thrope for pointing this out. -
@PeterJones Thank you for your detailed explanation. I’m indeed confused about the borders between Scintilla and Notepad++, I often don’t know where the one starts and the other ends.
But what I was really looking for, is a short description of the wParam named
IDM_SEARCH_MARKEDTOCLIP (43061)
. I was hoping for a description of the type one finds inPlugins > PythonScript > Context-Help
. I tried – perhaps clumsily – to generalize my question by phrasing it as a search for a description of awParam
defined in menuCmdID.h.I’ve searched in vain the context-help documents and the Npp user manual for a description of the
wParam = 43061
search method. As it seemed to me that there must be a well-defined algorithm to find it, I asked the question earlier in this thread. Even after reading your illuminating explanation, I did not succeed in finding a description of the search method that copies a marked string to the clipboard. -
@Paul-Wormer said in strange behavior with macro:
what I was really looking for, is a short description of the wParam named IDM_SEARCH_MARKEDTOCLIP
I’ve searched in vain the context-help documents and the Npp user manual for a description of the wParam = 43061
I did not succeed in finding a description of the search method that copies a marked string to the clipboard.
This is because what you are seeking to find does not exist.
(Thus your search was actually successful?) – :-)
IDM_SEARCH_MARKEDTOCLIP
/ 43061 are merely source code constructs. There is no further documentation about them.If you want to learn more about them, perhaps start with THIS SEARCH and go from there.
-
@Alan-Kilborn So then the question arises: how in the world did you know that the topic starter missed wParam = “43061” in her/his macro?
-
@Paul-Wormer said in strange behavior with macro:
how in the world did you know that the topic starter missed wParam = “43061” in her/his macro?
Well, when the OP said:
i think the issue is when paste copy marked text into new file.
…that was a big clue. :-)
So I went looking for specifically something related to that in a really short macro – it wasn’t hard to pinpoint the difficulty.And… the Copy Marked Text button is kind of an oddball in the Mark window, when you think about how the searching macros are encoded – it isn’t related to searching, but is rather something you do after searching.
It is on my TODO list to file a bug report about this, since it has confused at least one user so far. There’s a workaround (as I pointed out), but it is still confusing.
-
@Paul-Wormer said,
I’ve searched in vain the context-help documents and the Npp user manual for a description of the wParam = 43061
I did not succeed in finding a description of the search method that copies a marked string to the clipboard.And @Alan-Kilborn replied,
This is because what you are seeking to find does not exist.
It takes a little reading of the manual, and some intuition; there isn’t a nice simple name-to-description map, but the information is available. The user manual Macros section describes, in general, what the wParam is used for, and where to find details on the individual message:
Firstly, looking in menuCmdId.h , the name of the file gives a really big hint that each of the
IDM
constants corresponds to a Notepad++ menu entry … but it does take some intuition.Secondly, it also directs you to
localization\English.xml
, where it says to look for those numbers. If you were to find a number like43061
in that file, you would find one entry just labeled “Find Mark Style” in the “all menu item” <Commands> section (which would be confusing, because there are a series of entries near each other which all have that same name), but then the second instance of43061
in the <ShortcutMapper><MainCommandNames> is the more clear “Copy Styled Text of Find Mark style”.However, I will add a “TODO” to try to make it more clear that the Type-2 macro entries all correspond to an entry in Notepad++'s menu system.
-
@PeterJones I don’t have
localization\English.xml
, but I do haveC:\Users[..]\AppData\Roaming\Notepad++\nativeLang.xml
in which I found:<Item id="43061" name="Find Mark Style"/>
It takes lots of intuition and years of experience to associate this name with
SEARCH_MARKEDTOCLIP
.In any case, thank you for pointing me to this file.
-
@Paul-Wormer said in strange behavior with macro:
I don’t have localization\English.xml, but I do have C:\Users[…]\AppData\Roaming\Notepad++\nativeLang.xml
Just a guess, but I’d suppose when using an installed version of Notepad++ (which I do not do), that english.xml would be under a localization folder under the folder in which the notepad++.exe file lives?
-
@Paul-Wormer said in strange behavior with macro:
@PeterJones I don’t have
localization\English.xml
,Yes you do.
c:\program files\notepad++\localization\english.xml
, or wherever else your Notepad++ is installed – unless you didn’t install the English language localization when you did your installation (in which case, look in whichever language you do use). See Config Files Location in the manual. That’s wherenativeLang,xml
comes from (when you select your localization). But yes,nativeLang.xml
contains the same information, so if you cannot seem to findenglish.xml
, then use that instead.but I do have
C:\Users[..]\AppData\Roaming\Notepad++\nativeLang.xml
in which I found:<Item id="43061" name="Find Mark Style"/>
Umm. Did you not notice I said specifically,
you would find one entry just labeled “Find Mark Style” in the “all menu item” <Commands> section (which would be confusing, because there are a series of entries near each other which all have that same name), but then the second instance of 43061 in the <ShortcutMapper><MainCommandNames> is the more clear “Copy Styled Text of Find Mark style”.
I rather thought I covered that confusion with that sentence.
It takes lots of intuition and years of experience to associate this name with
SEARCH_MARKEDTOCLIP
.That’s why I told you to keep searching for the second instance, which is a more helpful name.
And you seem to have not understood my explanation. If you know the ID already (ie, reading an existing macro), you can easily figure out which menu entry it maps to by searching for that number in the english.xml (or equivalent). On the other hand, if you want to figure out the number for a given menu entry, look at the name of the menu entry, then look for that text in the english.xml (or equivalent), and see the id it is associated with. Once you have that number, then you can figure out the number from menuCmdId.h if you really want to (but you don’t need to – because you already know which command ID which goes to the menu entry you are interested in).
-
@Alan-Kilborn Yes indeed, I have
English.xml
underC:\Program Files\Notepad++\localization
. So, which of the two files takes precedence? Isn’t having two files a bit superfluous and therefore error prone? -
So, which of the two files takes precedence? Isn’t having two files a bit superfluous and therefore error prone?
-
@Paul-Wormer said in strange behavior with macro:
So, which of the two files takes precedence?
Typically, the stuff in “appdata” is what Notepad++ is using specifically for YOU. And when a localization file is put there by the program, it calls it nativeLang.xml.
If you’re using English, all of the others (French, Spanish, etc.) are choices you could make in the future, so until you do, the “sources” for these are left with the main program files, with their original names.
-
@PeterJones Yes, I take that back. I understood perfectly well your explanation that
43061
is the key in going fromFind Mark Style
toIDM_SEARCH_MARKEDTOCLIP
. But it takes intuition to realize that both names mean nothing more than: copy marked text to the clipboard. As Alan pointed out there is noFind
involved. The Npp search popup adds to the confusion by speaking aboutStyled Text
. I had no idea that styled text is the same as marked text, because I never looked into the text styling possibilities of N++. -
@Paul-Wormer said in strange behavior with macro:
the key in going from “Find Mark Style” to IDM_SEARCH_MARKEDTOCLIP
This may be the key part of Peter’s earlier reply for you:
but then the second instance of 43061 in the <ShortcutMapper><MainCommandNames> is the more clear “Copy Styled Text of Find Mark style”.
“Find Mark Style” is the bottom-level submenu text for the command. It may not convey full meaning until you combine it with the upper part, which is what “MainCommandNames” tries to do:
But it takes intuition to realize that both names mean nothing more than: copy marked text to the clipboard
I think my current answer explains it?
-
@Alan-Kilborn said in strange behavior with macro:
“Copy Styled Text of Find Mark style”
You really feel that “Copy Styled Text of Find Mark style” is clear? Talking about intuition …