Community
    • Login

    How do I add a macro to toolbar

    Scheduled Pinned Locked Moved General Discussion
    8 Posts 2 Posters 177 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.
    • Leszek HelakL
      Leszek Helak
      last edited by

      How do I add a macro to my toolbar?

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Leszek Helak
        last edited by PeterJones

        @Leszek-Helak ,

        Notepad++ does not natively allow adding new buttons to the Toolbar, without using a plugin.

        The Customize Toolbar plugin will allow you to do this.

        • Use Plugins > Plugins Admin to install Customize Toolbar (and restart Notepad++)
        • Use Plugins > Customize Toolbar > Custom Button to enable the custom button feature
        • Edit %AppData%\Notepad++\plugins\Config\CustomizeToolbar.btn to add the following two lines
          Macro,Trim Trailing Space and Save,,,*S:Tr,*S:Tr
          View,Show Symbol,Show All Characters,,*S:¶,*S:¶
          
          • The first line is the way to add the macro. Just use your exact macro name instead of Trim Trailing Space and Save.
          • The second line is to overcome a bug in the plugin (the plugin isn’t actively maintained, and it started adding extra spaces when Notepad++ improved the behavior of the [¶] “Show All Characters” button)
            • Note: a drawback to this is that it gets rid of Notepad++'s native icon for the action, which also includes a visible pulldown button to indicate there are options on the Toolbar:
              8c8abfc4-6bc2-41b4-8763-b5d46818c6ae-image.png
              To get the same pulldown when using the CustomizeToolbar, you have to right-click on the new icon:
              814c3d29-6130-4e4c-b780-6716775164bc-image.png
        • If you don’t like the colorful-text-as-icon provided by the Customize Toolbar for the Show All Characters, then you could follow my instructions in this reply in the bug report, which gives some example icons and shows you how to use those icons.
          Similarly, if you made a .BMP file and two .ICO files for your macro, and put them in the same directory, you could use the similar method for specifying the images for the macro’s icon. An example, based on the instructions in the bug report:
          Macro,Trim Trailing Space and Save,,,Icons\myMacro.bmp,Icons\myMacro_light.ico,Icons\myMacro_dark.ico
          View,Show Symbol,Show All Characters,,Icons\allChars.bmp,Icons\allChars_off.ico,Icons\allChars_off_dark.ico
          
        Leszek HelakL 1 Reply Last reply Reply Quote 3
        • Leszek HelakL
          Leszek Helak
          last edited by

          This method works only if the interface language is English. There are errors in another language.

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Leszek Helak
            last edited by

            @Leszek-Helak ,

            Please reply to this topic rather than creating a new topic. I had to merge your post in to this old topic to give it context.

            There are errors in another language.

            Could you be more specific? What errors? Can you share the name of the macro that causes problems?

            I have never had a macro with non-ASCII characters in the name, so I have no experience with it. And I don’t know how the internals of the CustomizeToolbar macro are written, so I don’t know how compatible that plugin is with non-ASCII characters. (Unfortunately, the author of that plugin doesn’t seem to be supporting it anymore, so it’s doubtful that any bugs that end up being in that plugin will be fixed. But if you give us more information, we might at least be able to come up with a workaround.)

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

              @Leszek-Helak ,

              CustomizeToolbar.btn needs to be a UTF-16-LE encoded file, so it can handle any Unicode character.

              CustomizeToolbar.btn contains:

              Macro,Äbc,,,*S:Ä,*S:Ä
              

              shortcuts.xml contains:

                      <Macro name="Äbc" Ctrl="no" Alt="no" Shift="no" Key="0">
                          <Action type="1" message="2170" wParam="0" lParam="0" sParam="Äbc" />
                      </Macro>
              

              That toolbar button works for me.

              But Ä is in the normal latin-1 range, so that might not be enough of a test.

              So I switched to some Cyrillic characters for the macro’s name and the text that gets typed, and the pseudo-icon on the toolbar:

              CustomizeToolbar.btn contains:

              Macro,АВГ,,,*S:Г,*S:Г
              

              shortcuts.xml contains:

                      <Macro name="АВГ" Ctrl="no" Alt="no" Shift="no" Key="0">
                          <Action type="1" message="2170" wParam="0" lParam="0" sParam="АВГ" />
                      </Macro>
              

              After restarting, that toolbar button also works for me.

              I mean, that’s not an exhaustive test, but since the Cyrillic are above codepoint 255, if it works for that, it should work for any Unicode characters.

              When you open/edit CustomizeToolbar.btn, does the lower-right corner of the status bar have “UTF-16 Little Endian”? And if you open %AppData%\Notepad++\shortcuts.xml, does it say “UTF-8”?

              Here’s a screenshot of mine for the CustomizeToolbar.btn file: notice the encoding in the lower-right
              e75335c2-05a9-4f49-be31-e0ba10e11b30-image.png

              One thing you can try is to copy my examples, because both of those are verified as working correctly for me. So you can see if those exact setups work for you, as well.

              If mine works for you, but yours do not, then using the </> button when making your reply, if you can paste in your exact CustomizeToolbar.btn and shortcuts.xml macro that’s giving you trouble, that would be really helpful to help us help you.

              Leszek HelakL 1 Reply Last reply Reply Quote 2
              • Leszek HelakL
                Leszek Helak @PeterJones
                last edited by

                @PeterJones
                In English isk OK
                168274cb-2f65-4edc-bd76-0f73c34b3547-obraz.png

                In German
                bd27ec0e-bdde-49c3-98c8-77a70c6189b8-obraz.png
                and second icon
                3c0c55c6-8dea-4e42-bf0e-2124b18a1730-obraz.png

                PeterJonesP 1 Reply Last reply Reply Quote 1
                • PeterJonesP
                  PeterJones @Leszek Helak
                  last edited by

                  @Leszek-Helak ,

                  Okay, now I understand.

                  In the CustomizeToolbar.btn, the menu-entry names must match your localization – the names must match what you see in your GUI

                  So it’s not Macro, it’s Makros (but the “Trim Trailing Space and Save” isn’t translated, because it’s not translated in your Macros menu, either)

                  And, because it’s not View > Show Symbol > Show All Characters when the localization is set to German, you have to use the translated strings

                  So with the CustomizeToolbar.btn defining those two buttons as

                  Ansicht,Symbole anzeigen,Alle Zeichen anzeigen,,*S:¶,*S:¶
                  Makros,Trim Trailing Space and Save,,,*S:Tr,*S:Tr
                  

                  and restart Notepad++, the buttons work right again:

                  8261cf91-8669-41cd-8eb8-c532c0a10c8f-image.png

                  To reiterate: the text you enter in the CustomizeToolbar.btn must match the text you see in the menus in your localization of Notepad++.

                  1 Reply Last reply Reply Quote 3
                  • Leszek HelakL
                    Leszek Helak @PeterJones
                    last edited by

                    @PeterJones
                    Thanks, I understand

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