Community
    • Login

    Where is the user macro file?

    Scheduled Pinned Locked Moved General Discussion
    19 Posts 5 Posters 3.7k 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.
    • PeterJonesP
      PeterJones @Harry Goldhagen
      last edited by

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

        @Harry-Goldhagen said in Where is the user macro file?:

        so I can go in and edit

        Probably it is best to attempt to record most of what you want to do, and have Notepad++ write it for you. Then, augment with any hand-edits things the recorder won’t do (it isn’t perfect, and won’t record all actions).

        with a line per character

        Do you mean to type a character into a document? If so, then yes, but in practice macros don’t really do a lot of that, or at least MY macros don’t. Maybe yours will? Don’t know what you have in mind.

        If you really want to dive into macros, you’ll want to obtain the menuCmdID.h file from the source code. This will help you decode/encode lines like these in shortcuts.xml:

                <Macro name="Trim Trailing Space and Save" Ctrl="no" Alt="no" Shift="no" Key="0">
                    <Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
                    <Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
                </Macro>
        

        …meaning what 42024 and 41006 are.

        Also, the section at the very bottom of THIS PAGE in the documentation (entitled “Searching actions when recorded as macros”) will help you understand how find-related macros are done. @PeterJones Any way to link more directly to that section?

        All that being said:
        Don’t get too excited about the macro feature.
        If you do you will probably be disappointed.
        You may want to turn to scripting which can do soooo much more.

        PeterJonesP 1 Reply Last reply Reply Quote 2
        • PeterJonesP
          PeterJones @Alan Kilborn
          last edited by

          @Alan-Kilborn said in Where is the user macro file?:

          @Harry-Goldhagen said in Where is the user macro file?:

          with a line per character

          Do you mean to type a character into a document? If so, then yes, but in practice macros don’t really do a lot of that, or at least MY macros don’t. Maybe yours will? Don’t know what you have in mind.

          Just some background: the reason the macro recorder does one line per character is the recorder is basically tracking “keystrokes” (clicks / menu commands / search dialog buttons / etc). Those same “typing” macro commands can and do allow strings of more than one character; it’s just the recorder cannot know that it’s going to be a longer “string”, so just records one character per action.

          If you really want to dive into macros, you’ll want to obtain the menuCmdID.h file from the source code. This will help you decode/encode lines like these in shortcuts.xml:

          Yeah, so menuCmdID.h has the type-2 actions. Scintilla.iface has the type-0 and type-1 action IDs. This is mentioned in the official docs in the <Macros> section of the Config File Details (https://npp-user-manual.org/docs/config-files/#macros)

          Also, the section at the very bottom of THIS PAGE in the documentation (entitled “Searching actions when recorded as macros”) will help you understand how find-related macros are done. @PeterJones Any way to link more directly to that section?

          https://npp-user-manual.org/docs/searching/#searching-actions-when-recorded-as-macros

          Oh, right, and something else to add to the docs: I need to link in the FindReplaceDlg_rc.h as the location for all those 1700 and similar “magic numbers” in the searching-actions.

          In some browsers, the TOC for the individual page will show up, and the links there have the anchors for each header available. Unfortunately, the magic CSS that knows when you’re on a mobile browser will often hide that TOC.
          06a7c5ac-e4bb-4ab2-bf44-a38ed7853091-image.png

          All that being said:
          Don’t get too excited about the macro feature.
          If you do you will probably be disappointed.
          You may want to turn to scripting which can do soooo much more.

          To put it differently: macros are good for sequential actions with no decision-making. For anything else, use a scripting plugin.

          Harry GoldhagenH 1 Reply Last reply Reply Quote 1
          • guy038G
            guy038
            last edited by guy038

            Hello, @harry-goldhagen, @peterjones, @alan-kilborn and All,

            @harry-goldhagen said :

            on first glance it seems like a very wordy macro language, with a line per character.

            This sentence caught my attention ! I said to myself: could we put several characters, together, in the same 2170 instruction ?


            For instance this simple text :

            Test
            Second line !
            

            will normally be recorded as :

                    <Macro name="Test" Ctrl="no" Alt="no" Shift="no" Key="0">
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="T" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="e" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="s" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="t" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="&#x000D;" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="&#x000A;" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="S" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="e" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="c" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="o" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="n" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="d" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="l" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="i" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="n" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="e" />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="!" />
                    </Macro>
            

            So, I tried to cut down all this stuff with this version :

                    <Macro name="Test_1" Ctrl="no" Alt="no" Shift="no" Key="0">
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="Test&#x000D;&#x000A;Second line !" />
                    </Macro>
            

            And guess what ? It works nicely and this text is kept over N++ sessions, without any problem !

            Note that it works with a very long sentence, too, as in this second test with the Preamble of the N++ license.txt file :

                    <Macro name="Test_2" Ctrl="no" Alt="no" Shift="no" Key="0">
                        <Action type="1" message="2170" wParam="0" lParam="0" sParam="The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too." />
                    </Macro>
            

            So, one more thing to remember !

            Alan, Peter, I hope that, this time, I don’t relay false news about the configuration file shortcuts.xml. Just experiment my assumption !

            Best Regards

            guy038

            P.S. :

            Very hard to type this message because my pussy has just settled between my keyboard and me ;-)) The naughty one !

            Harry GoldhagenH 1 Reply Last reply Reply Quote 1
            • Harry GoldhagenH
              Harry Goldhagen @guy038
              last edited by

              @guy038 Thanks everyone, lots to learn now! I’m just trying to simply automate web page creation for my static site.

              1 Reply Last reply Reply Quote 0
              • Harry GoldhagenH
                Harry Goldhagen @PeterJones
                last edited by

                @PeterJones I’m unfamiliar with scripting, is this also described in the manual? I have no programming skills, I only use Notepad++ for writing web pages and CSS files, so I’m hoping scripting is a straightforward feature…

                Alan KilbornA 1 Reply Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @Harry Goldhagen
                  last edited by

                  @Harry-Goldhagen said in Where is the user macro file?:

                  I’m unfamiliar with scripting, is this also described in the manual? I have no programming skills, I only use Notepad++ for writing web pages and CSS files, so I’m hoping scripting is a straightforward feature…

                  Because scripting is done with a plugin, it wouldn’t be in the N++ manual.

                  If you have “no programming skills”, probably best to stay away from scripting. Unless you have a burning desire to acquire some of those skills.

                  Harry GoldhagenH 1 Reply Last reply Reply Quote 3
                  • Harry GoldhagenH
                    Harry Goldhagen @Alan Kilborn
                    last edited by Harry Goldhagen

                    @Alan-Kilborn Thanks, looks like I’ll stick to macros! By the way, I must say this is one of the most helpful forums I’ve ever used! The NPP crowd is very helpful. Glad a friend of mine recommended that I use it for html coding.

                    Alan KilbornA 1 Reply Last reply Reply Quote 2
                    • Alan KilbornA
                      Alan Kilborn @Harry Goldhagen
                      last edited by

                      @Harry-Goldhagen said in Where is the user macro file?:

                      Glad a friend of mine recommended that I use it for html coding.

                      Just don’t ask your HTML coding questions here!
                      We don’t take kindly to that!
                      :-)

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

                        @PeterJones said in Where is the user macro file?:

                        @Alan-Kilborn said in Where is the user macro file?:

                        Peter, I don’t know that info currently in the manual is anywhere close to as good as what you (and possibly I, if you agree) have said in this thread.

                        Yep: usermanual issue #139 created and assigned to me.

                        Pull Request #140 submitted.

                        ( @Alan-Kilborn , during my investigation, I confirmed that cloud actually beats doLocalConf, rather than the other way around as you phrased it.)

                        Alan KilbornA 2 Replies Last reply Reply Quote 3
                        • Alan KilbornA
                          Alan Kilborn @PeterJones
                          last edited by

                          @PeterJones said in Where is the user macro file?:

                          I confirmed that cloud actually beats doLocalConf, rather than the other way around as you phrased it.

                          Interesting.
                          It seems like the xml file should beat everything else, but I guess not.
                          At least it is documented well now.
                          Thanks to your efforts.

                          1 Reply Last reply Reply Quote 1
                          • Alan KilbornA
                            Alan Kilborn @PeterJones
                            last edited by

                            @PeterJones

                            More upcoming work for Peter on this: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/9287

                            :-(

                            PeterJonesP 1 Reply Last reply Reply Quote 1
                            • PeterJonesP
                              PeterJones @Alan Kilborn
                              last edited by

                              @Alan-Kilborn said in Where is the user macro file?:

                              :-(

                              It’s only going to be another sentence or two. Not a killer addition. ;-)

                              created usermanual issue #141

                              1 Reply Last reply Reply Quote 1
                              • prahladmifourP
                                prahladmifour
                                last edited by prahladmifour

                                Hello,@Harry-Goldhagen
                                In Windows, the macros are saved at %AppData%\Notepad++\shortcuts.XML

                                Or

                                In Windows < 7 the macros are saved at C:\Documents and Settings%username%\Application Data\Notepad++\shortcuts.xml
                                In Windows 7|8|10 C:\Users%username%\AppData\Roaming\Notepad++\shortcuts.xml
                                Note: You will need to close Notepad++ if you have any new macros you want to ‘export’.

                                I hope this information will be useful to you.
                                Thank you.

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