Community
    • Login

    Using plug-ins in macro

    Scheduled Pinned Locked Moved General Discussion
    6 Posts 2 Posters 1.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.
    • Garry WeilG
      Garry Weil
      last edited by

      I am trying to create a macro which also uses the JSON Viewer -> Format JSON to “pretty print” some JSON. When I look at the macro in Shortcuts.xml there does not appear to be any lines associated with the execution of the plug-in from the NPP menu.

      Is it even possible to use plug-ins in a macro?

      Thanks in advance

      Notepad++ v8.1.9 (32-bit)
      Build time : Oct 21 2021 - 23:32:04
      Path : C:\Program Files (x86)\Notepad++\notepad++.exe
      Command Line :
      Admin mode : OFF
      Local Conf mode : OFF
      Cloud Config : OFF
      OS Name : Windows 10 Enterprise (64-bit)
      OS Version : 2009
      OS Build : 19042.1348
      Current ANSI codepage : 1252
      Plugins : ComparePlugin.dll JSLintNpp.dll mimeTools.dll NppConverter.dll NppExec.dll NppExport.dll NPPJSONViewer.dll NppUISpy.dll RegexTrainer.dll SpellChecker.dll

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Garry Weil
        last edited by

        @garry-weil ,

        You cannot record a macro to call a plugin menu command.

        However, you can manually create/edit the macro to insert those commands. To get the command ID, you need to use a plugin like NppUISpy – ooh, you already have it; great!. However, there is a caveat: plugin menu ID’s are not constant: if you add or remove a plugin, or if you update a plugin and it changes the number of menu entries, the command ID may change.

        For more on this, see this post, in which I show an example of the steps for adding an XML Tools menu command to the macro. The procedure for JSON Viewer would be similar.

        Garry WeilG 2 Replies Last reply Reply Quote 5
        • Garry WeilG
          Garry Weil @PeterJones
          last edited by

          @peterjones Thanks so much for your prompt response :)

          1 Reply Last reply Reply Quote 0
          • Garry WeilG
            Garry Weil @PeterJones
            last edited by

            @peterjones Looked at your linked post. This explains why all my macros were removed when I edited the shortcuts.xml. Anyway, my plug-in has a subcommand. Is there a way to specify that via a xParam ? There is also a keyboard shortcut for the subcommand. Is there a way to execute that in the macro?

            Thanks again

            Garry WeilG PeterJonesP 2 Replies Last reply Reply Quote 0
            • Garry WeilG
              Garry Weil @Garry Weil
              last edited by

              @PeterJones Nevermind, the wParam is already the plugin subcommand.

              1 Reply Last reply Reply Quote 0
              • PeterJonesP
                PeterJones @Garry Weil
                last edited by

                @garry-weil ,

                my plug-in has a subcommand. Is there a way to specify that via a xParam ?

                I am not sure what you mean by “subcommand”. In Windows menus, there are either separator lines, submenus, or command entries. Command IDs are only available for command entries, nothing else has a command ID.

                For example, as NppUISpy shows in my current Notepad++ environment:

                fc4147e2-4fd6-471b-a374-b0bbd1609728-image.png

                Plugins > Python Script is a submenu, so it has a command ID of “0”. Then it has some actions which are 22108-22111. Then it has a Scripts submenu with id=0. Then there is the startup script command entry inside that menu, with id=23034, another couple of submenus, then a script that is called aaa123 with id=23127. So if I wanted to run the aaa123 script from a macro, I could create a macro that calls that number, such as

                        <Macro name="Example" Ctrl="no" Alt="no" Shift="no" Key="0">
                            <Action type="2" message="0" wParam="23127" lParam="0" sParam="" />
                        </Macro>
                

                There is also a keyboard shortcut for the subcommand. Is there a way to execute that in the macro?

                If that keyboard shortcut is editable using the Notepad++ built-in shortcut mapper, then the chances are, it will be able to run that using the number that UI Spy shows you. But plugins can also define keyboard shortcuts not using the Shortcut Mapper (though that’s an evil practice, since it makes for unknown shortcut conflicts) – so having a shortcut is not a guarantee that the plugin is playing nice.

                (note: didn’t see your “nevermind” until after I had the whole post basically written, so I am including it for future readers, and you if you care to have the extra info)

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