Community
    • Login

    Marco's do not record and execute shortcuts.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    19 Posts 5 Posters 922 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 @Rens Duijsens
      last edited by

      @Rens-Duijsens,

      Sorry, you are right. That’s what I get for not testing before publishing code.

              <Macro name="DuijsensEdited" Ctrl="no" Alt="no" Shift="no" Key="0">
                  <Action type="0" message="2316" wParam="0" lParam="0" sParam="" />  <!--Home-->
                  <Action type="0" message="2013" wParam="0" lParam="0" sParam="" />  <!--Select All-->
                  <Action type="2" message="0" wParam="22064" lParam="0" sParam="" /> <!--Mime Encode with padding-->
                  <Action type="0" message="2013" wParam="0" lParam="0" sParam="" />  <!--Select All-->
                  <Action type="0" message="2178" wParam="0" lParam="0" sParam="" />  <!--Copy-->
              </Macro>
      

      The select/copy are scintilla commands, and so need type=“0” with the scintilla command number in the message=“####” – I had mistakenly handcrafted them assuming they would use Notepad++'s command IDs. But the Plugin commands are menu commands, and they need to be type=“2” with the menu command ID (from Spy!) going in the wParam=“###” … (You can, of course, use your name and keyboard shortcut information rather than mine.)

      The decode and the pretty print in your second macro will also both need to be type=“2” with the number in wParam

      Sorry for the confusion.

      Rens DuijsensR 1 Reply Last reply Reply Quote 5
      • Rens DuijsensR
        Rens Duijsens @Rens Duijsens
        last edited by

        @PeterJones

        IT WORKS!!!
        Damn…you have NO idea how happy I am with this.
        Thank you so much!
        You are my hero!

        8a5a6230-cc0b-4381-b80c-00a5d760c448-image.png
        826efa84-9ff7-4c3e-ad08-60f6ca866a34-image.png g

        88b9d599-421a-4854-8a6b-7662c049399e-image.png

        Alan KilbornA 1 Reply Last reply Reply Quote 7
        • Alan KilbornA
          Alan Kilborn @Rens Duijsens
          last edited by Alan Kilborn

          @Rens-Duijsens

          Three are a bit much, where one (at most) would have definitely sufficed.
          That definitely does look like you though!
          We’re glad that you were able to achieve your goal.
          You can also UPVOTE @PeterJones to show your appreciation.

          Rens DuijsensR 1 Reply Last reply Reply Quote 4
          • Rens DuijsensR
            Rens Duijsens @Alan Kilborn
            last edited by

            @Alan-Kilborn
            Yeah…sorry…This just opens up a whole bunch of automations that will make my work so much easier.
            It’s not just these two macro’s, but so much more.
            (I tried to edit my reply to take two down, but I can’t anymore)

            Upvote @PeterJones .
            Ow, yes…I absolutely want to do that…but I don’t see how. (yet)
            Where do I do that please?

            Alan KilbornA 1 Reply Last reply Reply Quote 0
            • Alan KilbornA
              Alan Kilborn @Rens Duijsens
              last edited by

              @Rens-Duijsens

              c0f59797-bb9d-4e75-87a3-d276eaf79c74-image.png

              On Peter’s posting, obviously, not your own.

              Rens DuijsensR 1 Reply Last reply Reply Quote 1
              • Rens DuijsensR
                Rens Duijsens @Alan Kilborn
                last edited by

                @Alan-Kilborn
                Ah, yes…I already did that.
                Thanks.

                1 Reply Last reply Reply Quote 0
                • Rens DuijsensR
                  Rens Duijsens @PeterJones
                  last edited by

                  @PeterJones
                  As part om my Macro, I want also to set the ‘Language’ automatically to “XML”.
                  I have tried several versions of the Macro lines.

                  <Action type="2" message="0" wParam="46006" lParam="0" sParam="" />  <!-- Set language to XML -->
                  

                  and also

                  <Action type="0" message="46006" wParam="0" lParam="0" sParam="" />  <!-- Set language to XML -->
                  

                  and several other versions as well.
                  Up to now, I have been unable to make this work.

                  How can I set the file Language to XML in a Macro please?

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

                    @Rens-Duijsens ,

                    You need to read and understand https://npp-user-manual.org/docs/config-files/#macros , which describes which commands require which parameters. Type0 and Type1 are for the Scintilla messages only; type2 are for menu commands (whether built-in, or the cheater version for plugins); type3 are search/replace commands. That section of the manual also tells you where you can look to find the possible message= values for the scintilla type 0 and 1 actions, and the built-in menu-command-IDs for type 2 actions; it also directs you to the right section of the Searching page for finding out how to use the type=3 search/replace Actions.

                    The Language menu entries are menu commands, so they must be type2.
                    Randomly trying type=0 for menu commands will not work.

                    I have a macro which, among other things, sets the language for the current document to “Perl”, and the following Action works to accomplish that.

                    <Action type="2" message="0" wParam="46013" lParam="0" sParam="" />
                    

                    Thus, your first type2 example should work.

                    Yes, the following macro correctly changes the Language to XML:

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

                    I do not know why it is not for you: maybe something you are doing after it in your macro is overriding that choice, or maybe you have a bug in your macro so it is not working at all.

                    My debug recommendation is to start by trying my short !!XML!! macro, and verify it works (it should, since it does for me); then start adding your additional commands (before and after) until it stops doing what you expect

                    mathlete2M Rens DuijsensR 2 Replies Last reply Reply Quote 3
                    • mathlete2M
                      mathlete2 @PeterJones
                      last edited by mathlete2

                      @PeterJones said in Marco's do not record and execute shortcuts.:

                      type2 are for menu commands (…) the following macro correctly changes the Language to XML:

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

                      Hmm, I can see the part in the Macros page that mentions type=2 messages, and that excerpt links to the menuCmdID.h source file. IDM_LANG is defined on line 474, where the base number appears to be 6000, not 4600 or 46000. How did you get 46006 for the XML language?

                      Edit: I now see that line 474 has IDM+6000, not simply 6000. IDM is on line 20, defined as 40000

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

                        @mathlete2 said in Marco's do not record and execute shortcuts.:

                        How did you get 46006 for the XML language?

                        https://github.com/notepad-plus-plus/notepad-plus-plus/blob/ec961c895c2e6c6bc0315ef07592bc3ccaa37208/PowerEditor/src/menuCmdID.h#L20

                        plus

                        https://github.com/notepad-plus-plus/notepad-plus-plus/blob/ec961c895c2e6c6bc0315ef07592bc3ccaa37208/PowerEditor/src/menuCmdID.h#L474

                        plus

                        https://github.com/notepad-plus-plus/notepad-plus-plus/blob/ec961c895c2e6c6bc0315ef07592bc3ccaa37208/PowerEditor/src/menuCmdID.h#L480

                        = ?


                        Or, maybe more accurately and easier to understand:

                        IDM = 40000
                        IDM_LANG = (IDM + 6000)
                        IDM_LANG_XML = (IDM_LANG + 6) = 46006
                        
                        Rens DuijsensR 1 Reply Last reply Reply Quote 3
                        • mathlete2M
                          mathlete2
                          last edited by mathlete2

                          In the menuCmdID source file, there are multiple comments of the form:

                          // IMPORTANT: If list above/below is modified, you have to change the value of...

                          Is it possible for IDM_LANG to be defined differently in another setup?

                          Also, when UDLs are created, do they get their own ID too? If so, where can users find this ID number?

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

                            @mathlete2 said in Marco's do not record and execute shortcuts.:

                            In the menuCmdID source file, there are multiple comments of the form:

                            // IMPORTANT: If list above/below is modified, you have to change the value of...

                            Is it possible for IDM_LANG to be defined differently in another setup?

                            If you recompile Notepad++. But stuff like that, Don doesn’t tend to change (or allow others to) – he set it up originally with plenty of space for each group, and I haven’t noticed any changes to those main “header” constants.

                            However, the “If list above/below” warnings are put before certain “end of list” constants, like the IDM_FILEMENU_LASTONE – the point of that comment is to developers/contributors: if you add a new command to the File menu, you have to change the definition of IDM_FILEMENU_LASTONE, because obviously the last one has changed. Usually those comments apply to a very specific pair of X,Y in “if X changed then you have to change the value of Y” – it doesn’t mean “everything below this comment must be changed”, it means “the specific line or two immediately following this comment must be changed”.

                            Also, some are “beginning of sub-list” constants, which may change, but not very often. For an example of such a change, see my final paragraph in this post, about IDM_LANG_USER.

                            Also, when UDLs are created, do they get their own ID too? If so, where can users find this ID number?

                            https://github.com/notepad-plus-plus/notepad-plus-plus/blob/ec961c895c2e6c6bc0315ef07592bc3ccaa37208/PowerEditor/src/menuCmdID.h#L570-L571

                            UDLs get dynamically-assigned numbers between 46180 and 46210; the order depends on what order Notepad++ processes the UDL languages in – so it should remain consistent from one run to the next, as long as you don’t change the number of UDL or name of UDL or filename of UDL (the latter two might change the order that they get processed in). And you can use NppUISpy! plugin to read the menu command IDs for those, just like you can for plugin menu actions:
                            cbb81bbe-ceaa-4faa-a26b-db1363cc33c5-image.png

                            And, as an example of the “beginning of sub-list” style changes, the offset for IDM_LANG_USER changed from 80 to 180 about 8 years ago, when Notepad++ added around 20 new languages – he shifted it by 100, to make sure there was room for future expansion, so that wouldn’t have to change again; in the intervening years it’s up to about 90 builtin languages, so I estimate it would take another 20 years before the number of langauges gets close to the current limit. That constant changing is not something you should worry about anytime soon.

                            1 Reply Last reply Reply Quote 4
                            • Rens DuijsensR
                              Rens Duijsens @PeterJones
                              last edited by

                              @PeterJones
                              It works now.

                              I started, as you suggested, with this macro and that worked just fine.

                              <Macro name="!!XML!!" Ctrl="no" Alt="no" Shift="no" Key="0">                 <!-- TEST -->
                              	<Action type="2" message="0" wParam="46006" lParam="0" sParam="" />  <!-- Set Language to XML -->
                              </Macro>
                              

                              So…then I played around with the position of the XML-Language setting and it turns out it works when done in the first step.

                              <Macro name="BASE64 Decode XML" Ctrl="yes" Alt="yes" Shift="yes" Key="106">    <!-- Ctrl/Shift/Num* -->
                                  <Action type="2" message="0" wParam="46006" lParam="0" sParam="" />        <!-- Set Language to XML -->
                                  <Action type="0" message="2316" wParam="0" lParam="0" sParam="" />         <!-- Home -->
                                  <Action type="0" message="2013" wParam="0" lParam="0" sParam="" />         <!-- Select All -->
                                  <Action type="2" message="0" wParam="22129" lParam="0" sParam="" />        <!-- Base64 Decode -->
                                  <Action type="2" message="0" wParam="22217" lParam="0" sParam="" />        <!-- Xml Pretty Print with Attribute Indent -->
                                  <Action type="0" message="2013" wParam="0" lParam="0" sParam="" />         <!-- Select All -->
                                  <Action type="0" message="2178" wParam="0" lParam="0" sParam="" />         <!-- Copy -->
                              </Macro>
                              
                              

                              Yes, I’m happy to tell you that this macro does exactly what I want.
                              Thank you again for you very helpful assistance.

                              7e1a0ad2-68e8-4909-9df4-70dd89a46886-image.png

                              1 Reply Last reply Reply Quote 3
                              • Rens DuijsensR
                                Rens Duijsens @Alan Kilborn
                                last edited by

                                @Alan-Kilborn
                                @mathlete2 said in Marco’s do not record and execute shortcuts.:

                                How did you get 46006 for the XML language?
                                

                                For me it was simply useing the NppUISpy plugin.

                                e0f24b37-86e9-46e7-bf1a-5181aa559383-image.png

                                Rens DuijsensR 1 Reply Last reply Reply Quote 2
                                • Rens DuijsensR
                                  Rens Duijsens @Rens Duijsens
                                  last edited by

                                  By the way.
                                  I have noticed that the numbers that can be used in the shortcut keys are not totally equal to the ‘normal’ keycodes and that not all keycodes can be used.
                                  So…I have created a list with keycodes that are valid and I mention the actual keys they represent.
                                  The list is just for the ‘key’ attribute and they can off cause (duh) be combined with Ctrl, Alt, Shift.

                                  If a number is not mentioned, that that means that Notepad++ registers this number als “Unlisted” and will not use it.
                                  I have tested the numbers 0 to 255.

                                  I hope this list is useful.
                                  Any corrections and/or additions are welcome.

                                  Key="8"    ==> Backspace
                                  Key="9"    ==> TAB
                                  
                                  Key="13"   ==> ENTER
                                  
                                  Key="27"   ==> ESC
                                  
                                  Key="32"   ==> Spacebar
                                  Key="33"   ==> Page up
                                  Key="34"   ==> Page Down
                                  Key="35"   ==> End
                                  Key="36"   ==> Home
                                  Key="37"   ==> Left
                                  Key="38"   ==> Up
                                  Key="39"   ==> Right
                                  
                                  Key="55"   ==> INS
                                  Key="46"   ==> DEL
                                  
                                  Key="48"   ==> 0
                                  Key="49"   ==> 1
                                  Key="50"   ==> 2
                                  Key="51"   ==> 3
                                  Key="52"   ==> 4
                                  Key="53"   ==> 5
                                  Key="54"   ==> 6
                                  Key="55"   ==> 7
                                  Key="56"   ==> 8
                                  Key="57"   ==> 0
                                  
                                  
                                  Key="65"   ==> A
                                  Key="66"   ==> B
                                  Key="67"   ==> C
                                  Key="68"   ==> D
                                  Key="69"   ==> E
                                  Key="60"   ==> F
                                  Key="71"   ==> G
                                  Key="72"   ==> H
                                  Key="73"   ==> I
                                  Key="74"   ==> J
                                  Key="75"   ==> K
                                  Key="76"   ==> L
                                  Key="77"   ==> M
                                  Key="78"   ==> N
                                  Key="79"   ==> O
                                  Key="80"   ==> P
                                  Key="81"   ==> Q
                                  Key="82"   ==> R
                                  Key="83"   ==> S
                                  Key="84"   ==> T
                                  Key="85"   ==> U
                                  Key="86"   ==> V
                                  Key="87"   ==> W
                                  Key="88"   ==> X
                                  Key="89"   ==> Y
                                  Key="90"   ==> Z
                                  
                                  Key="96"   ==> Numpad 0
                                  Key="97"   ==> Numpad 1
                                  Key="98"   ==> Numpad 2
                                  Key="99"   ==> Numpad 3
                                  Key="100"  ==> Numpad 4
                                  Key="101"  ==> Numpad 5
                                  Key="102"  ==> Numpad 6
                                  Key="103"  ==> Numpad 7
                                  Key="104"  ==> Numpad 8
                                  Key="105"  ==> Numpad 9
                                  Key="106"  ==> Numpad *
                                  Key="107"  ==> Numpad +
                                  Key="109"  ==> Numpad -
                                  Key="110"  ==> Numpad .
                                  Key="111"  ==> Numpad /
                                  Key="112"  ==> F1
                                  Key="113"  ==> F2
                                  Key="114"  ==> F3
                                  Key="115"  ==> F4
                                  Key="116"  ==> F5
                                  Key="117"  ==> F6
                                  Key="118"  ==> F7
                                  Key="119"  ==> F8
                                  Key="120"  ==> F9
                                  Key="121"  ==> F10
                                  Key="122"  ==> F11
                                  Key="123"  ==> F12
                                  
                                  Key="186"  ==> +
                                  Key="187"  ==> =
                                  Key="188"  ==> ,
                                  Key="189"  ==> -
                                  Key="190"  ==> +
                                  Key="191"  ==> /
                                  Key="192"  ==> ~
                                  
                                  Key="219"  ==> [
                                  
                                  Key="222"  ==> '
                                  
                                  Key="226"  ==> <
                                  
                                  1 Reply Last reply Reply Quote 1
                                  • guy038G
                                    guy038
                                    last edited by

                                    Hello, @rens-duijsens and All,

                                    • Apparently, you forgot the Key "40" ==> Down, in your list

                                    • The key INS is Key 45 ( and not 55 )

                                    • Some OEM keys seem missing too !

                                    Refer this post and the next posts, for further information :

                                    https://community.notepad-plus-plus.org/topic/19734/faq-list-of-notepad-key-combinations-available-for-shortcuts

                                    Best Regards,

                                    guy038

                                    1 Reply Last reply Reply Quote 2
                                    • mathlete2M mathlete2 referenced this topic on
                                    • First post
                                      Last post
                                    The Community of users of the Notepad++ text editor.
                                    Powered by NodeBB | Contributors