Community
    • Login

    List of all assigned keyboard shortcuts

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    47 Posts 17 Posters 29.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.
    • guy038G
      guy038
      last edited by guy038

      Hi, Scott and All,

      So, continuation of my previous post !

      Here is below, a third table, with the Windows Virtual Keys values, for the default US keyboard :

      *==================*========*=======*===================*
      |     VK Name      |  Hex   |  Dec  |      Notes        |
      *------------------*--------*-------*-------------------*
      |  VK_NULL         |  0x00  |    0  |                   |
      *==================*========*=======*===================*
      
      
      *==================*========*=======*===================*
      |  US keyboard   -   LEFT part   -   FIRST Row          |
      *------------------*--------*-------*-------------------*
      |     VK Name      |  Hex   |  Dec  |      Notes        |
      *------------------*--------*-------*-------------------*
      |  VK_ESCAPE       |  0x1B  |   27  |                   |
      |                  |        |       |                   |
      |  VK_F1           |  0x70  |  112  |                   |
      |  VK_F2           |  0x71  |  113  |                   |
      |  VK_F3           |  0x72  |  114  |                   |
      |  VK_F4           |  0x73  |  115  |                   |
      |                  |        |       |                   |
      |  VK_F5           |  0x74  |  116  |                   |
      |  VK_F6           |  0x75  |  117  |                   |
      |  VK_F7           |  0x76  |  118  |                   |
      |  VK_F8           |  0x77  |  119  |                   |
      |                  |        |       |                   |
      |  VK_F9           |  0x78  |  120  |                   |
      |  VK_F10          |  0x79  |  121  |                   |
      |  VK_F11          |  0x7A  |  122  |                   |
      |  VK_F12          |  0x7B  |  123  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   LEFT part   -   SECOND Row         !
      *------------------*--------*-------*-------------------*
      |  VK_OEM_3        |  0xC0  |  192  |  Key US  '~ `'    |
      |  VK_1            |  0x31  |   49  |                   |
      |  VK_2            |  0x32  |   50  |                   |
      |  VK_3            |  0x33  |   51  |                   |
      |  VK_4            |  0x34  |   52  |                   |
      |  VK_5            |  0x35  |   53  |                   |
      |  VK_6            |  0x36  |   54  |                   |
      |  VK_7            |  0x37  |   55  |                   |
      |  VK_8            |  0x38  |   56  |                   |
      |  VK_9            |  0x39  |   57  |                   |
      |  VK_0            |  0x30  |   48  |                   |
      |  VK_OEM_MINUS    |  0xBD  |  189  |  Key US  '_ -'    |
      |  VK_OEM_PLUS     |  0xBB  |  187  |  Key US  '+ ='    |
      |  VK_BACK         |  0x08  |    8  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   LEFT part   -   THIRD Row          |
      *------------------*--------*-------*-------------------*
      |  VK_TAB          |  0x09  |    9  |                   |
      |  VK_Q            |  0x51  |   81  |                   |
      |  VK_W            |  0x57  |   87  |                   |
      |  VK_E            |  0x45  |   69  |                   |
      |  VK_R            |  0x52  |   82  |                   |
      |  VK_T            |  0x54  |   84  |                   |
      |  VK_Y            |  0x59  |   89  |                   |
      |  VK_U            |  0x55  |   85  |                   |
      |  VK_I            |  0x49  |   73  |                   |
      |  VK_O            |  0x4F  |   79  |                   |
      |  VK_P            |  0x50  |   80  |                   |
      |  VK_OEM_4        |  0xDB  |  219  |  Key US  '{ ['    |
      |  VK_OEM_6        |  0xDD  |  221  |  Key US  '} ]'    |
      |  VK_OEM_5        |  0xDC  |  220  |  Key US  '| \'    |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   LEFT part   -   FOURTH Row         |
      *------------------*--------*-------*-------------------*
      |  VK_CAPITAL      |  0x14  |   20  |                   |
      |  VK_A            |  0x41  |   65  |                   |
      |  VK_S            |  0x53  |   83  |                   |
      |  VK_D            |  0x44  |   68  |                   |
      |  VK_F            |  0x46  |   70  |                   |
      |  VK_G            |  0x47  |   71  |                   |
      |  VK_H            |  0x48  |   72  |                   |
      |  VK_J            |  0x4A  |   74  |                   |
      |  VK_K            |  0x4B  |   75  |                   |
      |  VK_L            |  0x4C  |   76  |                   |
      |  VK_OEM_1        |  0xBA  |  186  |  Key US  ': ;'    |
      |  VK_OEM_7        |  0xDE  |  222  |  Key US  '" ''    |
      |  VK_RETURN       |  0x0D  |   13  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   LEFT part   -   FIFTH Row          |
      *------------------*--------*-------*-------------------*
      |  VK_SHIFT        |  0x10  |   16  |                   |
      |  VK_Z            |  0x5A  |   90  |                   |
      |  VK_X            |  0x58  |   88  |                   |
      |  VK_C            |  0x43  |   67  |                   |
      |  VK_V            |  0x56  |   86  |                   |
      |  VK_B            |  0x42  |   66  |                   |
      |  VK_N            |  0x4E  |   78  |                   |
      |  VK_M            |  0x4D  |   77  |                   |
      |  VK_OEM_COMMA    |  0xBC  |  188  |  Key US  '< ,'    |
      |  VK_OEM_PERIOD   |  0xBE  |  190  |  Key US  '> .'    |
      |  VK_OEM_2        |  0xBF  |  191  |  Key US  '? /'    |
      |  VK_SHIFT        |  0x10  |   16  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   LEFT part   -   SIXTH Row          |
      *------------------*--------*-------*-------------------*
      |  VK_CONTROL      |  0x11  |   17  |                   |
      |  VK_LWIN         |  0x5B  |   91  |                   |
      |  VK_MENU         |  0x12  |   18  |                   |
      |  VK_SPACE        |  0x20  |   32  |                   |
      |  VK_RWIN         |  0x5C  |   92  |                   |
      |  VK_APPS         |  0x5D  |   93  |                   |
      |  VK_CONTROL      |  0x11  |   17  |                   |
      *==================*========*=======*===================*
      
      
      *==================*========*=======*===================*
      |  US keyboard   -   MIDDLE part   -   FIRST Row        |
      *------------------*--------*-------*-------------------*
      |     VK Name      |  Hex   |  Dec  |      Notes        |
      *------------------*--------*-------*-------------------*
      |  VK_INSERT       |  0x2D  |   45  |                   |
      |  VK_HOME         |  0x24  |   36  |                   |
      |  VK_PRIOR        |  0x21  |   33  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   MIDDLE part   -   SECOND Row       |
      *------------------*--------*-------*-------------------*
      |  VK_DELETE       |  0x2E  |   46  |                   |
      |  VK_END          |  0x23  |   35  |                   |
      |  VK_NEXT         |  0x22  |   34  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   MIDDLE part   -   THIRD Row        |
      *------------------*--------*-------*-------------------*
      |  VK_UP           |  0x26  |   38  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   MIDDLE part   -   FOURTH Row       |
      *------------------*--------*-------*-------------------*
      |  VK_LEFT         |  0x25  |   37  |                   |
      |  VK_DOWN         |  0x28  |   40  |                   |
      |  VK_RIGHT        |  0x27  |   39  |                   |
      *==================*========*=======*===================*
      
      
      *==================*========*=======*===================*
      |  US keyboard   -   RIGHT part   -   FIRST Row         |
      *------------------*--------*-------*-------------------*
      |     VK Name      |  Hex   |  Dec  |      Notes        |
      *------------------*--------*-------*-------------------*
      |  VK_SNAPSHOT     |  0x2C  |   44  |                   |
      |  VK_SCROLL       |  0x91  |  145  |                   |
      |  VK_PAUSE        |  0x13  |   19  |                   |
      |  VK_ATTN         |  0xF6  |  246  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   RIGHT part   -   SECOND Row        |
      *------------------*--------*-------*-------------------*
      |  VK_NUMLOCK      |  0x90  |  144  |                   |
      |  VK_DIVIDE       |  0x6F  |  111  |                   |
      |  VK_MULTIPLY     |  0x6A  |  106  |                   |
      |  VK_SUBTRACT     |  0x6D  |  109  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   RIGHT part   -   THIRD Row         |
      *------------------*--------*-------*-------------------*
      |  VK_NUMPAD7      |  0x67  |  103  |                   |
      |  VK_NUMPAD8      |  0x68  |  104  |                   |
      |  VK_NUMPAD9      |  0x69  |  105  |                   |
      |  VK_ADD          |  0x6B  |  107  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   RIGHT part   -   FOURTH Row        |
      *------------------*--------*-------*-------------------*
      |  VK_NUMPAD4      |  0x64  |  100  |                   |
      |  VK_NUMPAD5      |  0x65  |  101  |                   |
      |  VK_NUMPAD6      |  0x66  |  102  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   RIGHT part   -   FIFTH Row         |
      *------------------*--------*-------*-------------------*
      |  VK_NUMPAD1      |  0x61  |   97  |                   |
      |  VK_NUMPAD2      |  0x62  |   98  |                   |
      |  VK_NUMPAD3      |  0x63  |   99  |                   |
      *------------------*--------*-------*-------------------*
      |  US keyboard   -   RIGHT part   -   SIXTH Row         |
      *------------------*--------*-------*-------------------*
      |  VK_NUMPAD0      |  0x60  |   96  |                   |
      |  VK_DECIMAL      |  0x6E  |  110  |                   |
      |  VK_RETURN       |  0x0D  |   13  |                   |
      *==================*========*=======*===================*
      
      
      *==================*========*=======*===================*
      |                  OTHER Virtual Keys                   |
      *------------------*--------*-------*-------------------*
      |  VK_CANCEL       |  0x03  |    3  |                   |
      |  VK_CLEAR        |  0x0C  |   12  |                   |
      |                  |        |       |                   |
      |  VK_KANA         |  0x15  |   21  |                   |
      |  VK_HANGUL       |  0x15  |   21  |                   |
      |  VK_JUNJA        |  0x17  |   23  |                   |
      |  VK_FINAL        |  0x18  |   24  |                   |
      |  VK_HANJA        |  0x19  |   25  |                   |
      |  VK_KANJI        |  0x19  |   25  |                   |
      |                  |        |       |                   |
      |  VK_CONVERT      |  0x1C  |   28  |                   |
      |  VK_NONCONVERT   |  0x1D  |   29  |                   |
      |  VK_ACCEPT       |  0x1E  |   30  |                   |
      |  VK_MODECHANGE   |  0x1F  |   31  |                   |
      |                  |        |       |                   |
      |  VK_SELECT       |  0x29  |   41  |                   |
      |  VK_PRINT        |  0x2A  |   42  |                   |
      |  VK_EXECUTE      |  0x2B  |   43  |                   |
      |  VK_HELP         |  0x2F  |   47  |                   |
      |                  |        |       |                   |
      |  VK_SLEEP        |  0x5F  |   95  |                   |
      |                  |        |       |                   |
      |  VK_SEPARATOR    |  0x6C  |  108  |                   |
      |                  |        |       |                   |
      |  VK_F13          |  0x7C  |  124  |                   |
      |  VK_F14          |  0x7D  |  125  |                   |
      |  VK_F15          |  0x7E  |  126  |                   |
      |  VK_F16          |  0x7F  |  127  |                   |
      |  VK_F17          |  0x80  |  128  |                   |
      |  VK_F18          |  0x81  |  129  |                   |
      |  VK_F19          |  0x82  |  130  |                   |
      |  VK_F20          |  0x83  |  131  |                   |
      |  VK_F21          |  0x84  |  132  |                   |
      |  VK_F22          |  0x85  |  133  |                   |
      |  VK_F23          |  0x86  |  134  |                   |
      |  VK_F24          |  0x87  |  135  |                   |
      |                  |        |       |                   |
      |  VK_OEM_8        |  0xDF  |  223  |                   |
      |                  |        |       |                   |
      |  VK_OEM_102      |  0xE2  |  226  |  Key US  '< >'    |
      |  VK_OEM_RESET    |  0xE9  |  233  |                   |
      |  VK_OEM_JUMP     |  0xEA  |  234  |                   |
      |  VK_OEM_PA1      |  0xEB  |  235  |                   |
      |  VK_OEM_PA2      |  0xEC  |  236  |                   |
      |  VK_OEM_PA3      |  0xED  |  237  |                   |
      |  VK_OEM_WSCTRL   |  0xEE  |  238  |                   |
      |  VK_OEM_CUSEL    |  0xEF  |  239  |                   |
      |                  |        |       |                   |
      |  VK_OEM_ATTN     |  0xF0  |  240  |                   |
      |  VK_OEM_FINISH   |  0xF1  |  241  |                   |
      |  VK_OEM_COPY     |  0xF2  |  242  |                   |
      |  VK_OEM_AUTO     |  0xF3  |  243  |                   |
      |  VK_OEM_ENLW     |  0xF4  |  244  |                   |
      |  VK_OEM_BACKTAB  |  0xF5  |  245  |                   |
      |  VK_CRSEL        |  0xF7  |  247  |                   |
      |  VK_EXSEL        |  0xF8  |  248  |                   |
      |  VK_EREOF        |  0xF9  |  249  |                   |
      |  VK_PLAY         |  0xFA  |  250  |                   |
      |  VK_ZOOM         |  0xFB  |  251  |                   |
      |  VK_NONAME       |  0xFC  |  252  |                   |
      |  VK_PA1          |  0xFD  |  253  |                   |
      |  VK_OEM_CLEAR    |  0xFE  |  254  |                   |
      *==================*========*=======*===================*
      

      Refer, also, to the two links below :

      https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

      http://ascii-table.com/keyboards.php

      Then, the remaining columns refer to a table, closed to the previous one, relative to the Shortcut Mapper, itself :

      • The 11th column notices, in which tab of the Shortcut Mapper, each command is indicated

      • The 12th column gives the ORDER number of each command, indicated in the Shortcut Mapper

      • The 13 column shows, when possible, the Scintilla name of each command

      • The 14th and last column, just displays possible notes, about each command, if any

      Remark : As this table is ordered, according to the occurring of commands in N++ menus, this same list, in the Shortcut Mapper table, may differ, in few locations, from the real list of the N++ Shortcut Mapper ( See, for instance, the set of the 8 Sort commands ! )

      guy038

      1 Reply Last reply Reply Quote 3
      • guy038G
        guy038
        last edited by guy038

        Hi, Scott and All,

        Final post !

        BTW, if, from that 700 lines list, you want to extract, in one go, the 191 default shortcuts, used in N++ v7.2, just perform the following S/R, in Regular expression mode, that deletes any line which does not have a VK name, ( different from VK_NULL ), inside the 8th column !

        SEARCH (?-s)^(?=.{108}(VK_NULL |[ -])).+\R

        REPLACE EMPTY

        So, from that narrowed list and/or from the complete one, you should easily update the list of all your own shortcuts, shouldn’t you ?

        Best Regards

        guy038

        1 Reply Last reply Reply Quote 2
        • Macgryver JohnsonM
          Macgryver Johnson
          last edited by Macgryver Johnson

          Hi @guy038
          I would really like to see your list.
          Can I get that list?
          Thanks in advance
          my email: macgyver204@gmail.com

          1 Reply Last reply Reply Quote 0
          • guy038G
            guy038
            last edited by

            Hi, Macgryver Johnson and Scott,

            I sent you my Synthesis.cpp file, few minutes ago, by e-mail to both of you

            Cheers

            guy038

            1 Reply Last reply Reply Quote 0
            • William RutkowskiW
              William Rutkowski
              last edited by

              https://drive.google.com/file/d/0B86nuTd5nMTKaENHcmliUC1kdnc/edit?usp=sharing

              This comes from the Notepad++ sites homepage. Scroll down to the bottom it is the last option. Hope it helps…Peace…

              1 Reply Last reply Reply Quote 1
              • IvyNoI
                IvyNo
                last edited by

                Hi,
                I know these posts are pretty old, but I hope I can still get the list.
                Would you please send it to my email ivy.noname@web.de
                Thanks a lot

                1 Reply Last reply Reply Quote 0
                • guy038G
                  guy038
                  last edited by

                  Hello, @IvyNo,

                  These next days, I’ll try to update the old list of Notepad++ and Scintilla commands, which I talk about in my first post of this thread, above. So, from the v7.2 version you’ll get the last v7.7 version of this file.

                  Remember that this file is, simply, a personal synthesis of some data from the 3 files Parameters.cpp, keys.h and menuCmdID.h, normally located in folder notepad-plus-plus-7.7\PowerEditor\src of the archive notepad-plus-plus-7.7.zip

                  So, please, let me a couple of days to get it right and I’ll send you this Synthesis.cpp file, as well as the default complete list of N++ v7.7 shortcuts, bye-mail ;-))

                  Best Regards,

                  guy038

                  1 Reply Last reply Reply Quote 4
                  • IvyNoI
                    IvyNo
                    last edited by

                    Hi Guy038,
                    Thanks a lot for your fast answer.
                    There is no hurry, take your time, I am happy to get the list, no matter when :-)
                    Kind regards

                    1 Reply Last reply Reply Quote 0
                    • guy038G
                      guy038
                      last edited by

                      Hi, @IvyNo,

                      Sorry for the long delay :-( First, I spent a week on vacation for a family celebration ( at the seaside !), then I helped a friend of my wife’s for computer problems and I had to prepare for my daughter’s future move, next Saturday ! And, of course, I delved into the source files of Notapad+++ 7.7.0 !

                      I sent you a mail, some minutes ago, with 6 attached files :

                      • Synthesis.cpp, which recapitulates all Notepad++ 7.7.0 internal commands and corresponding Scintilla messages

                      • SCI_list.cpp, which contains all messages and values of the ...\Scintilla\include\Scintilla.h file

                      • Shortcuts_list.cpp, which lists all default shortcuts of Notepad++ 7.7.0

                      and, for information :

                      • Define_list.cpp, which recapitulates all #define statements, referring to a numeric or string value, found in all the source files

                      • Enum_List.cpp, which contains all enumerations from the ...\Scintilla\include\Scintilla.iface file

                      • Keys_US.cpp, which lists all the scan codes of a traditional US keyboard

                      Note :

                      • These .cpp files could have been renamed as simple .txt files. But, by doing so, we just take advantage of the highlighting of numerical values and strings and of the folding, due to the pair { and } :-))

                      I just hope that you’ll find useful some part of all that stuff, anyway !

                      Best Regards,

                      guy038

                      1 Reply Last reply Reply Quote 3
                      • Дмитрий РыжовД
                        Дмитрий Рыжов
                        last edited by

                        Hi @guy038
                        I have been looking for a similar table for a long time. Can I see the results of your labors? jang.spb@gmail.com

                        1 Reply Last reply Reply Quote 0
                        • EkopalypseE
                          Ekopalypse
                          last edited by

                          If I could iterate through it in a python code snippet would work

                          Just in case some else has the same requirement

                          import ctypes
                          import ctypes.wintypes as wintypes
                          
                          user32 = ctypes.WinDLL('user32', use_last_error=True)
                          
                          NPP_HANDLE = user32.FindWindowW(u'Notepad++', None)
                          
                          MIIM_SUBMENU = 4
                          MIIM_STRING = 64
                          
                          class MENUITEMINFO(ctypes.Structure):
                              _fields_ = [ ("cbSize"       , wintypes.UINT),
                                           ("fMask"        , wintypes.UINT),
                                           ("fType"        , wintypes.UINT),
                                           ("fState"       , wintypes.UINT),
                                           ("wID"          , wintypes.UINT),
                                           ("hSubMenu"     , wintypes.HMENU),
                                           ("hbmpChecked"  , wintypes.HBITMAP),
                                           ("hbmpUnchecked", wintypes.HBITMAP),
                                           ("dwItemData"   , wintypes.LPVOID),  # ULONG_PTR
                                           ("dwTypeData"   , wintypes.LPWSTR),
                                           ("cch"          , wintypes.UINT),
                                           ("hbmpItem"     , wintypes.HBITMAP),]
                          
                          npp_menu_handle = user32.GetMenu(NPP_HANDLE)
                          
                          def get_configured_shortcuts(menu_handle):
                              menu_items = user32.GetMenuItemCount(menu_handle)
                              for item in range(menu_items):
                                  uitem = item
                                  fByPosition = True
                                  mii = MENUITEMINFO()
                                  mii.cbSize = ctypes.sizeof(mii)
                                  mii.fMask = MIIM_STRING | MIIM_SUBMENU
                                  lpmii = ctypes.byref(mii)
                          
                                  user32.GetMenuItemInfoW(menu_handle,
                                                          uitem,
                                                          fByPosition,
                                                          lpmii)
                          
                                  if mii.hSubMenu:
                                      get_configured_shortcuts(mii.hSubMenu)
                          
                                  mii.dwTypeData = ctypes.cast(ctypes.create_unicode_buffer(mii.cch+1), ctypes.c_wchar_p)
                                  mii.cch = mii.cch+1
                                  mii.cbSize = ctypes.sizeof(mii)
                                  user32.GetMenuItemInfoW(menu_handle,
                                                       uitem,
                                                       fByPosition,
                                                       lpmii)
                          
                                  if '\t' in mii.dwTypeData:
                                      shortcuts.append(mii.dwTypeData.split('\t'))
                          
                          
                          shortcuts = []
                          for i in range(user32.GetMenuItemCount(npp_menu_handle)):
                              submenu_handle = user32.GetSubMenu(npp_menu_handle, i)
                              get_configured_shortcuts(submenu_handle)
                          
                          _max_length = len(max([x[0] for x in shortcuts], key=len))
                          notepad.new()
                          editor.setText('\r\n'.join(['{0:<{2}} : {1}'.format(x[0], x[1], _max_length) for x in shortcuts]))
                          
                          Alan KilbornA 1 Reply Last reply Reply Quote 2
                          • Alan KilbornA
                            Alan Kilborn @Ekopalypse
                            last edited by

                            @Ekopalypse

                            Interesting approach to get some of the shortcuts. :)

                            EkopalypseE 1 Reply Last reply Reply Quote 0
                            • EkopalypseE
                              Ekopalypse @Alan Kilborn
                              last edited by

                              @Alan-Kilborn

                              Why some? What did I miss?

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

                                @Ekopalypse

                                Well, just as one example, most (if not all) Scintilla commands that have shortcuts in Shortcut Mapper are not output by the script.

                                EkopalypseE 1 Reply Last reply Reply Quote 2
                                • EkopalypseE
                                  Ekopalypse @Alan Kilborn
                                  last edited by Ekopalypse

                                  @Alan-Kilborn

                                  You are right, how could I miss those?
                                  Damn it.

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

                                    @Ekopalypse

                                    I have seen this thread before, but didn’t have any new ideas about it. When I saw your recent efforts, I thought it was interesting as I hadn’t thought about that kind of approach. So now I’m thinking, if the Shortcut Mapper info is left in memory (after being invoked once?), could some ctypes magic find it and report it? I don’t know enough about the internals, IIRC doesn’t it use something called BabyGrid or something like that?

                                    EkopalypseE 2 Replies Last reply Reply Quote 2
                                    • EkopalypseE
                                      Ekopalypse @Alan Kilborn
                                      last edited by

                                      @Alan-Kilborn

                                      if the Shortcut Mapper info is left in memory (after being invoked once?), could some ctypes magic find it and report it

                                      Not sure about it, digging in npps memory seems to be a dangerous place :-D

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

                                        Maybe it would be best if N++ itself had a feature to export this infos. :P

                                        EkopalypseE 1 Reply Last reply Reply Quote 1
                                        • EkopalypseE
                                          Ekopalypse @Alan Kilborn
                                          last edited by Ekopalypse

                                          @Alan-Kilborn

                                          the shortcut mapper dialog seems to be the trusted source in this situation, isn’t it?
                                          As it is a blocking dialog we start it in a different thread and then searching for the tabsyscontrol
                                          and then with some magic ctypes we should be able to get the shortcuts currently configured.
                                          Hmm, fun project - I guess I’ll give it a try :-)

                                          1 Reply Last reply Reply Quote 2
                                          • EkopalypseE
                                            Ekopalypse @Alan Kilborn
                                            last edited by

                                            @Alan-Kilborn

                                            unfortunately TCM_SETCURSEL doesn’t trigger babygrid to be updated therefore I had to use keybd_event but seems to work.

                                            import ctypes
                                            import ctypes.wintypes as wintypes
                                            from threading import Thread
                                            import time
                                            
                                            user32 = ctypes.WinDLL('user32', use_last_error=True)
                                            
                                            def start_sk_dialog():
                                                notepad.menuCommand(MENUCOMMAND.SETTING_SHORTCUT_MAPPER)
                                            
                                            
                                            sk_mapper = Thread(target=start_sk_dialog)
                                            sk_mapper.start()
                                            time.sleep(1)
                                            
                                            WM_USER = 1024
                                            WM_CLOSE = 16
                                            
                                            TCM_FIRST = 4864
                                            TCM_GETITEMCOUNT = (TCM_FIRST + 4)
                                            TCM_SETCURSEL = (TCM_FIRST + 12)
                                            
                                            BABYGRID_USER = (WM_USER + 7000)
                                            BGM_GETCELLDATA  = BABYGRID_USER + 4
                                            BGM_GETROWS  = BABYGRID_USER + 23
                                            
                                            class BGCELL(ctypes.Structure):
                                                _fields_ = [('row', wintypes.INT),
                                                            ('col', wintypes.INT)]
                                            
                                            cell_buffer = ctypes.create_unicode_buffer(1000)
                                            
                                            bgcell = BGCELL()
                                            
                                            sk_mapper_hwnd = user32.FindWindowW(None, u'Shortcut mapper')
                                            sys_tab_hwnd = user32.FindWindowExW(sk_mapper_hwnd, None, u'SysTabControl32',None)
                                            item_count = user32.SendMessageW(sys_tab_hwnd, TCM_GETITEMCOUNT, 0, 0)
                                            babygrid = user32.FindWindowExW(sk_mapper_hwnd, None, u'BABYGRID',None)
                                            
                                            shortcuts = []
                                            for tab in range(item_count):
                                                rows = user32.SendMessageW(babygrid, BGM_GETROWS, 0, 0)
                                                print 'rows', rows
                                            
                                                for i in range(1, rows+1):
                                                    shortcut = []
                                                    for j in range(1,3):
                                                        bgcell.row = i
                                                        bgcell.col = j
                                                        res = user32.SendMessageW(babygrid,
                                                                          BGM_GETCELLDATA,
                                                                          ctypes.byref(bgcell),
                                                                          cell_buffer)
                                                        shortcut.append(cell_buffer.value)
                                                    shortcuts.append(shortcut)
                                            
                                                user32.SetForegroundWindow(sk_mapper_hwnd)
                                                user32.SendMessageW(sys_tab_hwnd, TCM_SETCURSEL, tab, 0)
                                                user32.keybd_event(0x27,0,0,0)
                                                user32.keybd_event(0x27,0,2,0)
                                            
                                            user32.SendMessageW(sk_mapper_hwnd, WM_CLOSE, 0, 0)
                                            
                                            _max_length = len(max([x[0] for x in shortcuts if x[1]], key=len))
                                            notepad.new()
                                            editor.setText('\r\n'.join(['{0:<{2}} : {1}'.format(x[0], x[1], _max_length) for x in shortcuts if x[1]]))
                                            
                                            Alan KilbornA 1 Reply Last reply Reply Quote 2
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors