• Login
Community
  • Login

HELP: Having trouble with Macros in v8.5.3 or later

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
28 Posts 9 Posters 5.8k 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
    PeterJones
    last edited by PeterJones May 24, 2023, 7:30 PM May 18, 2023, 1:46 PM

    This topic was created as a catch-all for people who need help with fixing their macros after switching to Notepad++ v8.5.3 (or later), but for whom the FAQ was not sufficient – the FAQ even directs you here to ask further questions about the situation.

    Admins might even move posts to be a part of this topic, rather than staying where they were originally asked.

    Please make sure that any post in this topic indicates that you have, in fact, read the FAQ, and have at least tried to follow the advice. When you post here, please include the ?-menu’s Debug Info, as well as the steps that you personally tried while trying to get your macros fixed.

    For those who have not seen the FAQ, click below:

    FAQ Desk: v8.5.3 Macros and Run-Menu Commands

    M 1 Reply Last reply May 25, 2023, 4:53 PM Reply Quote 2
    • G
      Grath777
      last edited by PeterJones May 18, 2023, 1:56 PM May 18, 2023, 1:37 PM

      I am in the early stages of tracking an issue with Find/Replace using Macros in the 8.5.3 build… In my particular case, I am doing find/replace in Regular Expression mode where the find and replace fields also both include a tab character which we define in the macro thusly:

      	
      

      Might be related to the “Add the UTF8 character ability for Run & Macro menu” fixes?

      Have confirmed rolling back to 8.5.2 restores expected functionality.

      I will TRY to experiment a little more to better define the issue, but am using N++ in a production environment and needed to get it working again.

      I at least wanted to get a post up here about it so those much smarter than me might be able to solve it.

      Thanks to @donho and the entire team. LOVE N++!!!

      ----
      Admin Note: moved this post from the Notepad++ v8.5.3 Release to keep all the discussion about this issue in one location.

      P 2 Replies Last reply May 18, 2023, 1:42 PM Reply Quote 1
      • P
        PeterJones @Grath777
        last edited by PeterJones May 18, 2023, 1:48 PM May 18, 2023, 1:42 PM

        @Grath777 said in Notepad++ v8.5.3 Release:

        Might be related to the “Add the UTF8 character ability for Run & Macro menu” fixes?

        Definitely related. We created a FAQ about the changes required to previous macros and user-defined commands

        I moved your post to a “Help Wanted” topic dedicated to this issue, rather than allowing our back-and-forth to clutter the “annoucement” topic.

        G 1 Reply Last reply May 18, 2023, 1:48 PM Reply Quote 0
        • G
          Grath777 @PeterJones
          last edited by May 18, 2023, 1:48 PM

          Thank you, @PeterJones! I actually had just stumbled upon that post after making mine. Appreciate you. I will read through that and report back if I continue to have any issues, but I suspect that will answer all my questions.

          Thanks again!

          G 1 Reply Last reply May 18, 2023, 1:57 PM Reply Quote 1
          • P PeterJones referenced this topic on May 18, 2023, 1:51 PM
          • G
            Grath777 @Grath777
            last edited by May 18, 2023, 1:57 PM

            @PeterJones Confirmed that took care of everything. Thanks again!

            1 Reply Last reply Reply Quote 1
            • P
              PeterJones @Grath777
              last edited by May 18, 2023, 2:00 PM

              @Grath777 said in HELP: Having trouble with Macros in v8.5.3 or later:

              I am doing find/replace in Regular Expression mode where the find and replace fields also both include a tab character which we define in the macro thusly

              Searching for or replacing a tab character in a Regular Expression doesn’t need to have the tab character encoded like that: you can use the regular expression syntax \t in both the Find What and Replace With fields and have it work. So in your macro source, where you had a 	 in a search or replace field (so in the sParam="..." of the message="1601" for Find What and in the sParam="..." of the message="1602" for Replace With, per Search and Replace Macros in the User Manual ), you could just use a \t instead, which will avoid all the macro issues.

              D 1 Reply Last reply May 21, 2023, 5:22 PM Reply Quote 1
              • P PeterJones pinned this topic on May 18, 2023, 2:02 PM
              • D
                datatraveller1 @PeterJones
                last edited by May 21, 2023, 5:22 PM

                @PeterJones I have a macro which inserts a new line:
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="&#x000D;" />
                <Action type="1" message="2170" wParam="0" lParam="0" sParam="&#x000A;" />

                &#x000D;&#x000A; gets inserted literally instead of a new line (CR/LF) with version v8.5.3. I tried to use “\n” instead but this gets inserted literally too. What am I doing wrong?

                D 1 Reply Last reply May 21, 2023, 8:30 PM Reply Quote 0
                • D
                  datatraveller1 @datatraveller1
                  last edited by May 21, 2023, 8:30 PM

                  So I have found the solution (thanks to @PeterJones) in the FAQ:
                  Find what: &#x000D; Replace With: \x{000D}
                  Find what: &#x000A; Replace With: \x{000A}
                  with Search mode set to Regular Expression and run Replace All.

                  1 Reply Last reply Reply Quote 1
                  • G
                    guy038
                    last edited by guy038 May 22, 2023, 5:20 AM May 22, 2023, 4:09 AM

                    Hello, @datatraveller1, @peterjones and All,

                    @datatraveller1, I do not think that your macro really adds a line-break when you use the \x{000D} and \x{000A} syntax in the <Macros> node of your shortcut.xml file, in N++ v8.5.3

                    Personally, adding the following section, in my portable N++ v5.8.3 installation :

                            <Macro name="ABC + Line-Break" Ctrl="no" Alt="no" Shift="no" Key="0">
                                <Action type="1" message="2170" wParam="0" lParam="0" sParam="A" />
                                <Action type="1" message="2170" wParam="0" lParam="0" sParam="B" />
                                <Action type="1" message="2170" wParam="0" lParam="0" sParam="C" />
                                <Action type="1" message="2170" wParam="0" lParam="0" sParam="\x{000D}" />
                                <Action type="1" message="2170" wParam="0" lParam="0" sParam="\x{000a}" />
                            </Macro>
                    

                    Results, when running this macro in a new tab, by the insertion of the literal text ABC\x{000D}\x{000A}


                    Whereas, selecting the string, between the double-quotes of the sParam attribute, and :

                    • Hitting the ALT key and, pressing simultaneously the 0, 1 and 3 keys, on the numeric keypad, does insert a true CR character

                    • Hitting the ALT key and, pressing simultaneously the 0, 1 and 0 keys, on the numeric keypad, does insert a true LF character

                    In the last two lines Action of the macro and gives this text :

                            <Macro name="ABC + Line-Break" Ctrl="no" Alt="no" Shift="no" Key="0">
                                <Action type="1" message="2170" wParam="0" lParam="0" sParam="A" />
                                <Action type="1" message="2170" wParam="0" lParam="0" sParam="B" />
                                <Action type="1" message="2170" wParam="0" lParam="0" sParam="C" />
                                <Action type="1" message="2170" wParam="0" lParam="0" sParam="
                    " />
                                <Action type="1" message="2170" wParam="0" lParam="0" sParam="
                    " />
                            </Macro>
                    

                    IMPORTANT : If you paste this text in a new tab, don’t forget to change the line-break of two last lines with CR and LF, instead of keeping two CRLF lines !

                    Just select the two chars CRLF of the last two lines and use the ALT + numeric keypad method to change the first line-break as CR and the second one as LF. Delete any non-intentional leading TAB chars, too.


                    Running this last version of the macro does write the ABC string followed with a Windows line-break CRLF ;-))

                    My debug info :

                    Notepad++ v8.5.3   (64-bit)
                    Build time : May 15 2023 - 06:09:36
                    Path : E:\853_x64\notepad++.exe
                    Command Line : 
                    Admin mode : OFF
                    Local Conf mode : ON
                    Cloud Config : OFF
                    OS Name : Windows 10 Pro (64-bit)
                    OS Version : 22H2
                    OS Build : 19045.2965
                    Current ANSI codepage : 1252
                    Plugins : 
                        mimeTools (2.9)
                        NppConverter (4.5)
                        NppExport (0.4)
                    

                    Best Regards,

                    guy038

                    D P 2 Replies Last reply May 22, 2023, 7:58 AM Reply Quote 1
                    • D
                      datatraveller1 @guy038
                      last edited by May 22, 2023, 7:58 AM

                      Hi @guy038 thank you, CR and LF got inserted as real line breaks with the FAQ solution:

                      80ce0429-952a-433f-a7dc-4f822701271c-image.png

                      1 Reply Last reply Reply Quote 1
                      • W
                        wonkawilly
                        last edited by May 24, 2023, 6:00 AM

                        I am having that kind of trubble my self too. I am getting errors of encoding in simple strings with accents for example with the use of the following caracters: à ù ò.
                        Please have a look at the following picture:

                        88ecb38d-989a-48bc-8f71-29247bc804ad-image.png

                        Maybe the new implementation is not yet complete.

                        Thank for reading.

                        1 Reply Last reply Reply Quote 0
                        • G
                          guy038
                          last edited by guy038 May 24, 2023, 8:21 AM May 24, 2023, 7:02 AM

                          Hello, @wonkawilly and All,

                          Finally, @wonkawilly, here is the right way to enter any character according to the new behaviour of macros, in N++ v.8.5.3!


                          • Open your active shortcuts.xml file in Notepad++

                          • Insert the empty template, below, at the end of the Macros section, right before </Macros>, in your shortcuts.xml file :

                                  <Macro name="Test" Ctrl="no" Alt="no" Shift="no" Key="0">
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="" />
                                  </Macro>
                          
                          • Duplicate the line <Action type="1" message="2170" wParam="0" lParam="0" sParam="" />, as many times as the number of chars to be inserted, incuding a possible line-break, with the Ctrl + D shortcut

                          => In your exemple, we’ll add four lines

                                  <Macro name="Test" Ctrl="no" Alt="no" Shift="no" Key="0">
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="" />
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="" />
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="" />
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="" />
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="" />
                                  </Macro>~~~
                          
                          • Put your caret/cursor between the two double-quotes of each sParam attribute

                          • Open the Edit > Character Panel menu option

                          • Double-click on the characters to insert, located under the ‘Character’ column of the Character Panel. Thus, for the line-break chars, just double-click on CR, then LF !

                          => We get this functional macro :

                                  <Macro name="Test" Ctrl="no" Alt="no" Shift="no" Key="0">
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="è" />
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="ò" />
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="ù" />
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="
                          " />
                                      <Action type="1" message="2170" wParam="0" lParam="0" sParam="
                          " />
                                  </Macro>
                          
                          • Save your shortcuts.xml file

                          • Close and restart N++

                          Enjoy your Test macro !

                          Best Regards,

                          guy038

                          W 1 Reply Last reply May 24, 2023, 7:35 AM Reply Quote 0
                          • W
                            wonkawilly @guy038
                            last edited by May 24, 2023, 7:35 AM

                            @guy038 said in HELP: Having trouble with Macros in v8.5.3 or later:

                            here is the right way to enter any character according to the new behaviour of macros, in N++ v.8.5.3!

                            The right way became a little bit more cumbersome than before… I rather like to write whole string with the keyboard or even better by voice.

                            I have to say that if there is a thing that I really hate about N++ since the first usage is the macro system. I would like to see it replaced with a better language for example js, py, cs or else, keeping the capability to record commands executed into N++ and adding the possibility to modify a macro written into a real and serious programming language that is easily human readable and modifiable than the macro system actually implemented that is really ugly.

                            D 1 Reply Last reply May 24, 2023, 8:12 AM Reply Quote 0
                            • D
                              datatraveller1 @wonkawilly
                              last edited by datatraveller1 May 24, 2023, 9:25 AM May 24, 2023, 8:12 AM

                              @wonkawilly As far as I have understood @guy038 and the FAQ, you simply have to replace the old values UTF-8 encoded literally with è, à etc.

                              I’m not sure if something like Python would work for the macro system but I partly agree that it is a bit ugly sometimes - In my case I don’t like that real line breaks get inserted into shortcuts.xml.

                              W 1 Reply Last reply May 27, 2023, 7:04 AM Reply Quote 3
                              • G
                                guy038
                                last edited by guy038 May 24, 2023, 7:26 PM May 24, 2023, 8:23 AM

                                Hi, @wonkawilly, @datatraveller1 and all,

                                But, of course, if a character is available on your keyboard, you may, as well, just type in this character !!

                                It’s only for special chars as line-break chars and some others that you need the help of the Character Panel

                                For instance, for the line-break chars, just use the method, described in my post to @datatraveller1, using ALT + 013 and ALT + 010, on the numeric keypad

                                BR

                                guy038

                                P.S :

                                @datatraveller1, The best when creating macros is to open the Character Panel, first and :

                                • Double-click on [ CR and ] LF, each time you want to insert a line-break in a macro

                                • Double-click on any character when this char is not available on your keyboard !

                                1 Reply Last reply Reply Quote 1
                                • Alan KilbornA
                                  Alan Kilborn
                                  last edited by May 24, 2023, 11:48 AM

                                  Certainly copy and paste of a character from another source also works fine as an alternative to using the Character Panel, which has a limited number of possible characters anyway.

                                  But, as stated, probably Character Panel is a good choice for carriage-return and line-feed characters.

                                  1 Reply Last reply Reply Quote 2
                                  • P
                                    PeterJones @guy038
                                    last edited by PeterJones May 24, 2023, 8:00 PM May 24, 2023, 7:44 PM

                                    I was going back through some of the posts here, to see if there are improvements that can be made to the FAQ.

                                    @guy038,

                                    I do not think that your macro really adds a line-break when you use the \x{000D} and \x{000A} syntax in the <Macros> node of your shortcut.xml file, in N++ v8.5.3

                                    I think you misread @datatraveller1: you seemed to asssume he changed to the literal

                                    <Action type="1" message="2170" wParam="0" lParam="0" sParam="\x{000D}" />
                                    <Action type="1" message="2170" wParam="0" lParam="0" sParam="\x{000A}" />
                                    

                                    If that had been the case, it wouldn’t work. But based on the “find what” and “replace with” in the post you replied to, he actually followed the advice found in the FAQ, which is when editing shortcuts.xml to use Notepad++ Replace window to run a regex search-and-replace. Using the “find what” and “replace with” that @datatraveller1 mentioned, and which I suggested in the FAQ, will change the &#x000D; sequence to the actual CR character and &#x000A; with the actual LF character.

                                    Later, @guy038 also wrote:

                                    Duplicate the line <Action type="1" message="2170" wParam="0" lParam="0" sParam="" />, as many times as the number of chars to be inserted, including a possible line-break, with the Ctrl + D shortcut

                                    There’s no need. The macro recorder just puts one character per 2170-message, but that’s not a restriction of the macro playback. If you are editing a macro and want to insert the text èòù[CRLF], the single action

                                    <Action type="1" message="2170" wParam="0" lParam="0" sParam="èòù
                                    " />
                                    

                                    will work (assuming the linebreak in the sParam is really a CR and LF)

                                    That said, based on what I’ve re-read here, I will suggest the Alt+013 and Alt+010 methods of entering those characters, and using the Character Panel (or Run > Run… > charmap.exe) for entering characters that aren’t on your keyboard.

                                    1 Reply Last reply Reply Quote 2
                                    • G
                                      guy038
                                      last edited by guy038 May 25, 2023, 7:23 AM May 25, 2023, 4:03 AM

                                      Hello, @wonkawilly, @datatraveller1, @alan-kilborn and all,

                                      Oh… Of course, I forgot to mention that, in my previous posts, I refered to macros already created by a user with a N++ version prior to v8.5.3 !

                                      If, with N++ v.8.5.3, you just create a new macro, containing one or several line-break(s), it’ll be correctly recorded !

                                      However, I noticed some oddities when recording these line-breaks !


                                      Follow these different actions for testing :

                                      • Open N++ v.8.5.3

                                      • Open a new tab

                                      • If the line-break format of the new tab is not Windows (CR LF), in the status bar, change it with the command Edit > EOL Conversion > Windows (CR LF)

                                      • Start recording a macro with the command Macro > Start Recording

                                      • In the new tab, just type in the string ABC and hit the Enter key

                                      • Then, type in the string DEF and hit , again, the Enter key

                                      • Stop recording the current macro with the command Macro > Stop Recording

                                      • Click on the the menu option Macro > Save Current Recorded Macro...

                                      • Give the name Test_CRLF to this macro

                                      • Delete all contents of this new tab with a Ctrl + Z operation

                                      • Change the EOL format of the new tab to Unix, with the command Edit > EOL Conversion > Unix (LF)

                                      • Start recording a macro with the command Macro > Start Recording

                                      • In the new tab, just type in the string GHI and hit the Enter key

                                      • Then, type in the string JKL and hit , again, the Enter key

                                      • Stop recording the current macro with the command Macro > Stop Recording

                                      • Click on the the menu option Macro > Save Current Recorded Macro...

                                      • Give the name Test_LF to this macro

                                      • Delete all contents of this new tab with a Ctrl + Z operation

                                      • Change the EOL format of the new tab to Mac, with the command Edit > EOL Conversion > Macintosh (CR)

                                      • Start recording a macro with the command Macro > Start Recording

                                      • In the new tab, just type in the string MNO and hit the Enter key

                                      • Then, type in the string PQR and hit , again, the Enter key

                                      • Stop recording the current macro with the command Macro > Stop Recording

                                      • Click on the the menu option Macro > Save Current Recorded Macro...

                                      • Give the name Test_CR to this macro

                                      • Close N++ v.8.5.3, without saving the new tab

                                      • Restart N++ v.8.5.3

                                      • Open your active shortcuts.xml file

                                      • Note the contents of the three macros Test_CRLF , Test_LF and Test_CR :

                                        • In the Test_CRLF macro, the first part of each EOL recording is the CR character ( OK ) but the second part is CRLF and not LF ( ?? )

                                        • In the Test_LF macro, the two EOL recording are the CRLF characters and not the LF chars ( ?? )

                                        • In the Test_CR macro, the two EOL recording are correctly the CR characters ( OK )

                                      I don’t know, if we should trigger an GitHub issue for these oddities ??

                                      Best Regards

                                      guy038

                                      P.S. : I’ve just seen the @peterjones’s post… and will have a look at it !

                                      Alan KilbornA 1 Reply Last reply May 25, 2023, 11:49 AM Reply Quote 2
                                      • Alan KilbornA
                                        Alan Kilborn @guy038
                                        last edited by Alan Kilborn May 25, 2023, 11:50 AM May 25, 2023, 11:49 AM

                                        @guy038 said in HELP: Having trouble with Macros in v8.5.3 or later:

                                        Note the contents of the macros Test_CRLF , Test_LF

                                        I can duplicate your poor results with these two. :-(

                                        if we should trigger an GitHub issue for these oddities ??

                                        Either that, or post about it in the 8.5.3 release thread, HERE.

                                        1 Reply Last reply Reply Quote 1
                                        • G guy038 referenced this topic on May 25, 2023, 1:05 PM
                                        • M
                                          Massimo Piscopo @PeterJones
                                          last edited by May 25, 2023, 4:53 PM

                                          I’ve a similar problem.
                                          I’ve created a macro doing a lot of things, included changing “word” into ‘word’ (look for ‘ ’ instead of " ").
                                          This worked ok until last update (8.5.3, build May 15 2023 06:07:16).
                                          Now the macro (I don’have touched it) change “word” into

                                          & # x 2 0 1 8 ; w o r d & # x 2 0 1 8 ;

                                          Please ignore spaces: if I don’t insert spaces, this forum convert “& # x 2 0 1 8 ; w o r d & # x 2 0 1 8 ;” into " ‘word’ " and it’s impossible to understand what I mean.
                                          I need Notepad++ don’t “convert” the ‘ ’ symbols.

                                          I’ve tried to search my macro recorded but I don’t find it in shortcuts.xml. Where I can find it? My macro is called “calcio (prime correzioni)” but in shortcuts.xml I find only “Trim Trailing Space and Save”. BTW the date of shortcuts.xml is from 2021 and maybe my macro was created after.

                                          P 1 Reply Last reply May 25, 2023, 6:38 PM Reply Quote 0
                                          2 out of 28
                                          • First post
                                            2/28
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors