4

I placed the following code in a init.m notebook that executes upon Mathematica startup. This creates a shortcut menu command that allows me to insert a page break by pressing Control+p. You can see the shortcut in the insert menu dropdown.

FrontEndExecute[FrontEnd`AddMenuCommands["DuplicatePreviousOutput",{MenuItem["Page Break",FrontEnd`KernelExecute[NotebookWrite[InputNotebook[],Cell["", "PageBreak", PageBreakBelow -> True],After]],FrontEnd`MenuKey["p",FrontEnd`Modifiers->{"Control"}],System`MenuEvaluator->Automatic]}]];

Let's say I want to change the shortcut from Control+p to Control+l. If I run the init.m file again with the modified code while Mathematica is already running it keeps the old shortcut which I don't want. You can see both by clicking the insert drop down menu.

Is there a way to erase the first shortcut by executing the init.m file without rebooting Mathematica? That is is there a command I can put at the top the init.m file that will erase the previous version?

I want to reinitialize so that erases the previously executed shortcut and installs the new one without rebooting? Any help would be greatly appreciated.

B flat
  • 5,523
  • 2
  • 14
  • 36

1 Answers1

2

Please try this from John Fultz via MathGroup Archive.

FrontEndExecute[FrontEnd`ResetMenusPacket[{Automatic}]]
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • 1
    Thank you. I placed your code in the init.m file at the top and tried executing without rebooting Mathematica. It did not erase the old command in the insert menu. I then tried executing the code in a regular notebook but had the same result. It doesn't seem to reset the commands i created using the AddMenuCommands functions. – B flat Mar 11 '19 at 03:47
  • @MichaelMcCain That's unfortunate; I seem to remember this working in the past but I didn't test it at this time. I shall try later, but I am (still) using version 10.1. What version are you using? – Mr.Wizard Mar 11 '19 at 03:51
  • 1
    No problem. Yes, by the link you sent it did seem to work in earlier versions. I am running 11.3 on a mac running 10.14.3 – B flat Mar 11 '19 at 03:52