Community
    • Login

    Macro does not record my Run action

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    17 Posts 4 Posters 366 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.
    • Victorel PetrovichV
      Victorel Petrovich @PeterJones
      last edited by

      @PeterJones
      Great walk-through.
      You knew how the menu IDs are assigned, so you were able to design the proper experiment.

      I have just performed an equivalent one where I created 2 Run-menu actions, then manually included the second one in a macro; tested fine; then deleted the first Run-menu action and restarted N++.
      When calling my macro, it, predictably, failed for the reasons you mentioned (in fact, it crashed N++).

      A question in your step 3 above:

      <Macro name="Do BC" Ctrl="no" Alt="no" Shift="no" Key="0">
              <Action type="2" message="0" wParam="20002" lParam="0" sParam="0" />
              <Action type="2" message="0" wParam="20003" lParam="0" sParam="0" />
          </Macro>
      

      shouldn’t sParam be "" ? based on https://npp-user-manual.org/docs/config-files/#attributes-for-the-action-tag
      Same in your example in https://community.notepad-plus-plus.org/topic/25400/faq-automating-notepad/2?_=1756438181968

      Now to the main part:

      It is 100% repeatable: it renumbered the macros every time one was inserted or deleted from the sequence, invalidating the wParam value used.

      Same happens when Run-menu items are inserted/removed from that menu; I guess similar thing happens with plugin menu.

      This pinpoints the core issue and also a possible solution/ fix to N++ code that deals with menu ID (re)assignments:
      The menu ID for a command should be kept constant.

      (Up until that command is removed by the user.)

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Victorel Petrovich
        last edited by

        @Victorel-Petrovich said in Macro does not record my Run action:

        shouldn’t sParam be "" ?

        That would be better, yes. They ignore the sParam unless it’s one of the string-related actions, but for consistency’s sake, it should just be "". (I copy/pasted the line from a different macro, and didn’t notice it has the sParam="0" for that one)

        The menu ID for a command should be kept constant.

        That would be the easiest, from the hacker perspective. But since we are breaking the macro “contract” by trying to include non-recorded actions in a macro, we’re already past the edge into unsupported behavior; I am doubtful that storing/allocating a “constand commandID” in the XML would be implemented just to support a few hackers who aren’t following the intended behavior of macros.

        I believe that the “official position” is that if you are doing something that doesn’t work with a recorded macro, you should instead switch to something like NppExec or PyhonScript plugins, instead of trying to use the macro system. I’m not sure he’s noticed how much I abuse the macro system, nor the fact that I have a FAQ explaining it. ;-) And I am really not sure I want this pointed out to him, lest he close the security gaps in the macro system.

        Victorel PetrovichV 2 Replies Last reply Reply Quote 1
        • Victorel PetrovichV
          Victorel Petrovich @PeterJones
          last edited by Victorel Petrovich

          @PeterJones Since there is no official list of what is supposed to work/ be recordable with macros and what not, I don’t think there is any “contract” here.
          My impression is that, at least with regards to these dynamic-ID menu commands, the current situation is simply a result of the coding solutions that were deemed good-enough long time ago and then the developers never had enough time/incentive to change it.

          But if enough people will agree that macros become much more powerful by including any Run/Macro/Plugin commands, then N++ code could be changed, for the better.

          It’s also about the long term vision for Macros: is it desirable to make them more powerful, to give more power to the average user that doesn’t have time to learn scripting, or not?
          (IMO, it makes it easier even for those who know scripting)

          I already found some raw initial algorithms for making the user’s menu-command IDs constant - if other people want to work with the C++ part.

          I’m not sure he’s noticed how much I abuse the macro system

          I don’t think you are abusing it; you’re simply working around the current limitations.
          That’s normal: any software has limitations; no software is perfect from the get-go. It evolves.

          Alan KilbornA Victorel PetrovichV 2 Replies Last reply Reply Quote 0
          • Victorel PetrovichV
            Victorel Petrovich @PeterJones
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • Alan KilbornA
              Alan Kilborn @Victorel Petrovich
              last edited by

              @Victorel-Petrovich said:

              I already found some raw initial algorithms for making the user’s menu-command IDs constant

              Great.

              if other people want to work with the C++ part.

              Why not YOU?

              Victorel PetrovichV 1 Reply Last reply Reply Quote 0
              • Victorel PetrovichV
                Victorel Petrovich @Alan Kilborn
                last edited by Victorel Petrovich

                @Alan-Kilborn if I knew it, I would.
                Another big part is being more or less familiar with the organization and specifics of N++ code.

                Alan KilbornA 1 Reply Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @Victorel Petrovich
                  last edited by

                  @Victorel-Petrovich

                  How come it seems like the people will all these grand ideas for how the code should be changed have no ability to do it?

                  Victorel PetrovichV 1 Reply Last reply Reply Quote 0
                  • Victorel PetrovichV
                    Victorel Petrovich @Alan Kilborn
                    last edited by Victorel Petrovich

                    @Alan-Kilborn it just seems to you so. Just like it seems to you that my ideas are “great” and “grand”.

                    1 Reply Last reply Reply Quote 0
                    • Victorel PetrovichV
                      Victorel Petrovich @Victorel Petrovich
                      last edited by

                      @Victorel-Petrovich said in Macro does not record my Run action:

                      It’s also about the long term vision for Macros: is it desirable to make them more powerful, to give more power to the average user that doesn’t have time to learn scripting, or not?

                      https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4809#issuecomment-3239606439

                      Victorel PetrovichV 1 Reply Last reply Reply Quote 0
                      • Victorel PetrovichV Victorel Petrovich referenced this topic on
                      • Victorel PetrovichV
                        Victorel Petrovich @Victorel Petrovich
                        last edited by Victorel Petrovich

                        @Victorel-Petrovich Another good idea: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8037

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors