• Login
Community
  • Login

strange behavior with macro

Scheduled Pinned Locked Moved General Discussion
28 Posts 4 Posters 3.4k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    pinuzzu99
    last edited by pinuzzu99 Mar 20, 2023, 9:18 AM Mar 20, 2023, 8:59 AM

    from my prev thread i’ve make a new simply macro:

    • from Mark (regex) https.*?\.jpg then click on Mark all
    • copy marked text and paste into new file
    • line operation - del empty lines
    • line operation - del duplicate lines

    this macro work fine when i make it
    but when re-open np++ and run this macro, i don’t have all steps recorded but on new file i’ve only paste from clipboard …! (the latest clipboard)
    weird. never see that. also i’ve other macro but all my macro work well, without problems. suggestion ?

    if i do all the steps manually, it works well ! …
    obviously i’ve deleted this macro and recreated with the same steps, but i’ve always same behavior

    A 1 Reply Last reply Mar 20, 2023, 11:32 AM Reply Quote 0
    • A
      Alan Kilborn @pinuzzu99
      last edited by Mar 20, 2023, 11:32 AM

      @pinuzzu99

      Perhaps open your shortcuts.xml file and find the Macros section and then paste whatever is between <Macro ...> and </Macro> for the problem one?

      Be sure to paste it into a “code block” (use the </> button).

      1 Reply Last reply Reply Quote 1
      • P
        pinuzzu99
        last edited by pinuzzu99 Mar 20, 2023, 1:53 PM Mar 20, 2023, 1:50 PM

        ``` <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

        A 1 Reply Last reply Mar 20, 2023, 1:53 PM Reply Quote 1
        • A
          Alan Kilborn @pinuzzu99
          last edited by Mar 20, 2023, 1:53 PM

          @pinuzzu99

          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…

          A 1 Reply Last reply Mar 20, 2023, 2:16 PM Reply Quote 1
          • A
            Alan Kilborn @Alan Kilborn
            last edited by Alan Kilborn Mar 20, 2023, 2:16 PM Mar 20, 2023, 2:16 PM

            @pinuzzu99

            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)
            
            P 1 Reply Last reply Mar 21, 2023, 4:41 PM Reply Quote 1
            • P
              pinuzzu99
              last edited by Mar 20, 2023, 4:05 PM

              wow, great solution!
              it work fine. thank you for this wonderful solution.

              All the best

              1 Reply Last reply Reply Quote 1
              • P
                Paul Wormer @Alan Kilborn
                last edited by Mar 21, 2023, 4:41 PM

                @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?

                P 1 Reply Last reply Mar 21, 2023, 5:10 PM Reply Quote 0
                • P
                  PeterJones @Paul Wormer
                  last edited by PeterJones Mar 21, 2023, 8:00 PM Mar 21, 2023, 5:10 PM

                  @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":

                  1. menuCmdID.h shows
                  #define    IDM_SEARCH_MARKEDTOCLIP         (IDM_SEARCH + 61)
                  
                  1. Look for the first occurrence of IDM_SEARCH , which shows
                  #define    IDM_SEARCH    (IDM + 3000)
                  
                  1. The #define for IDM near the top
                  #define    IDM    40000
                  
                  1. 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.

                  P 1 Reply Last reply Mar 22, 2023, 10:19 AM Reply Quote 3
                  • P
                    Paul Wormer @PeterJones
                    last edited by Mar 22, 2023, 10:19 AM

                    @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 in Plugins > PythonScript > Context-Help. I tried – perhaps clumsily – to generalize my question by phrasing it as a search for a description of a wParam 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.

                    A 1 Reply Last reply Mar 22, 2023, 11:01 AM Reply Quote 0
                    • A
                      Alan Kilborn @Paul Wormer
                      last edited by Alan Kilborn Mar 22, 2023, 11:03 AM Mar 22, 2023, 11:01 AM

                      @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.

                      P P 2 Replies Last reply Mar 22, 2023, 11:49 AM Reply Quote 1
                      • P
                        Paul Wormer @Alan Kilborn
                        last edited by Mar 22, 2023, 11:49 AM

                        @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?

                        A 1 Reply Last reply Mar 22, 2023, 12:01 PM Reply Quote 0
                        • A
                          Alan Kilborn @Paul Wormer
                          last edited by Alan Kilborn Mar 22, 2023, 12:03 PM Mar 22, 2023, 12:01 PM

                          @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.

                          1 Reply Last reply Reply Quote 1
                          • P
                            PeterJones @Alan Kilborn
                            last edited by PeterJones Mar 22, 2023, 2:03 PM Mar 22, 2023, 1:03 PM

                            @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 like 43061 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 of 43061 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.

                            P 1 Reply Last reply Mar 22, 2023, 1:50 PM Reply Quote 0
                            • P
                              Paul Wormer @PeterJones
                              last edited by Paul Wormer Mar 22, 2023, 1:51 PM Mar 22, 2023, 1:50 PM

                              @PeterJones I don’t have localization\English.xml, but I do have C:\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.

                              A P 2 Replies Last reply Mar 22, 2023, 1:55 PM Reply Quote 0
                              • A
                                Alan Kilborn @Paul Wormer
                                last edited by Mar 22, 2023, 1:55 PM

                                @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?

                                P 1 Reply Last reply Mar 22, 2023, 2:08 PM Reply Quote 2
                                • P
                                  PeterJones @Paul Wormer
                                  last edited by PeterJones Mar 22, 2023, 2:05 PM Mar 22, 2023, 2:02 PM

                                  @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 where nativeLang,xml comes from (when you select your localization). But yes, nativeLang.xml contains the same information, so if you cannot seem to find english.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).

                                  P 1 Reply Last reply Mar 22, 2023, 2:29 PM Reply Quote 1
                                  • P
                                    Paul Wormer @Alan Kilborn
                                    last edited by Mar 22, 2023, 2:08 PM

                                    @Alan-Kilborn Yes indeed, I have English.xml under C:\Program Files\Notepad++\localization. So, which of the two files takes precedence? Isn’t having two files a bit superfluous and therefore error prone?

                                    P A 2 Replies Last reply Mar 22, 2023, 2:10 PM Reply Quote 0
                                    • P
                                      PeterJones @Paul Wormer
                                      last edited by Mar 22, 2023, 2:10 PM

                                      @Paul-Wormer ,

                                      So, which of the two files takes precedence? Isn’t having two files a bit superfluous and therefore error prone?

                                      6f1ddf8c-3062-4f46-940a-f671486e49e4-image.png

                                      1 Reply Last reply Reply Quote 2
                                      • A
                                        Alan Kilborn @Paul Wormer
                                        last edited by Mar 22, 2023, 2:22 PM

                                        @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.

                                        1 Reply Last reply Reply Quote 2
                                        • P
                                          Paul Wormer @PeterJones
                                          last edited by Mar 22, 2023, 2:29 PM

                                          @PeterJones Yes, I take that back. I understood perfectly well your explanation that 43061 is the key in going from Find Mark Style to IDM_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 no Find involved. The Npp search popup adds to the confusion by speaking about Styled 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++.

                                          A 1 Reply Last reply Mar 22, 2023, 2:31 PM Reply Quote 0
                                          4 out of 28
                                          • First post
                                            4/28
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors