Notepad++ main menu: use/execute commands

  • DV

    DV - 2013-03-10

    To use/execute a command from Notepad++ main menu, one can use "npp_sendmsg NPPM_MENUCOMMAND 0 <Command_ID>" (such as "npp_sendmsg NPPM_MENUCOMMAND 0 IDM_SEARCH_FIND"). To get the IDs of standard (internal) Notepad++'s commands, refer to "menuCmdID.h" either from Notepad++'s sources or under your folder Notepad++\plugins\NppExec. 
    Regarding the syntax of npp_sendmsg and the examples, type "help npp_sendmsg" in NppExec's Console. 
    Now you may ask: what about menu items created by user or by plugins, can I use them in similar way? 
    Currently I am not sure if it is possible. I was trying to use NPPM_MENUCOMMAND here - but it worked with static (standard) menu items only, whereas custom (user's) and plugin's menu items seem to have generic (dynamic) menu items IDs. You can try to dig in this direction - though in case if you are not familiar with such things as "menu item id" and "SendMessage", I wouldn't recommend to dig since "Warning: incorrect usage of this command (npp_sendmsg) may crash Notepad++ !!!". 
    Note: While I mentioned NPPM_MENUCOMMAND, I assumed there was a small chance that the dynamic menu items under "Run… F5" item would have increasing item IDs - thus making possible to call them via "npp_sendmsg NPPM_MENUCOMMAND 0 IDM_EXECUTE+1" and so on. But this doesn't seem to be the case - the menu item id of (IDM_EXECUTE+2) does not correspond to "Launch in Firefox" or "Launch in IE" menu item. The same is regarding plugin's menu items - we need to get their IDs, but how? 
    Please share your thoughts regarding this. 

  • DV

    DV - 2013-03-13

    Next version of NppExec will introduce a new command to run a menu item command by a full name of that menu item. For example: 
    NPP_MENUCOMMAND Plugins|NppExec|Help/About… 
    NPP_MENUCOMMAND View//Move/Clone Current Document//Move to Other View 
    (notice usage of "//" to differ it from a single "/" which is a part of item's name; alternatively you can use "|" or "\" to separate different parts of menu item name)

  • DV

    DV - 2013-03-14

    Please ignore the second example above, it's wrong. The correct one is 
    NPP_MENUCOMMAND View\\Move/Clone Current Document\\Move to Other View 
    (We can not use // since it means a comment by default - i.e. everything after the first // will be cut.)


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks