Skip to main content
edited title
Link
user64494
  • 29.1k
  • 4
  • 29
  • 56

How do I add a button on the notebook menu bar to execute a number of keystrokes similar to a macro in Excel?

Edit based on comment from Kuba
Source Link
Rogo
  • 950
  • 4
  • 11

Reading past efforts to "Macrofy" Mathematica, it appears that the choice is between "FrontEndExecute" and a ResourceFunction "AddMenuItem" both of which are daunting. I do not want to modify the front end and foul up all my other Mathematica activities. Presently I am regularly pasting a graphic into a notebook which I then want to center and make the cell unevaluatable. Doing that requires typing

<alt>RACCPV

It would be nice to program a hotkey for that.

@Kuba sent me in the right direction but the code example there

<|"Label" -> "Center", "ShortKey" -> "c", "Action" :>FrontEndExecute[{SelectionMove[InputNotebook[], All, CellContents], 
NotebookDelete@InputNotebook[]}]|>

represents just the danger I wish to avoid (my comment about "daunting" is like the other comment in this thread about FrontEndExecute entailing too much "burden"). While I know better than to evaluate something that deletes my entire notebook, what I do not know is what to substitute in its place. A snippet of code for my particular needs is what I am missing. Sorry to be such a wimp...

Reading past efforts to "Macrofy" Mathematica, it appears that the choice is between "FrontEndExecute" and a ResourceFunction "AddMenuItem" both of which are daunting. I do not want to modify the front end and foul up all my other Mathematica activities. Presently I am regularly pasting a graphic into a notebook which I then want to center and make the cell unevaluatable. Doing that requires typing

<alt>RACCPV

It would be nice to program a hotkey for that.

Reading past efforts to "Macrofy" Mathematica, it appears that the choice is between "FrontEndExecute" and a ResourceFunction "AddMenuItem" both of which are daunting. I do not want to modify the front end and foul up all my other Mathematica activities. Presently I am regularly pasting a graphic into a notebook which I then want to center and make the cell unevaluatable. Doing that requires typing

<alt>RACCPV

It would be nice to program a hotkey for that.

@Kuba sent me in the right direction but the code example there

<|"Label" -> "Center", "ShortKey" -> "c", "Action" :>FrontEndExecute[{SelectionMove[InputNotebook[], All, CellContents], 
NotebookDelete@InputNotebook[]}]|>

represents just the danger I wish to avoid (my comment about "daunting" is like the other comment in this thread about FrontEndExecute entailing too much "burden"). While I know better than to evaluate something that deletes my entire notebook, what I do not know is what to substitute in its place. A snippet of code for my particular needs is what I am missing. Sorry to be such a wimp...

added 10 characters in body
Source Link
Rogo
  • 950
  • 4
  • 11

Reading past efforts to "Macrofy" Mathematica, it appears that the choice is between "FrontEndExecute" and a ResourceFunction "AddMenuItem" both of which are daunting. I do not want to modify the front end and foul up all my other Mathematica activities. Presently I am regularly pasting a graphic into a notebook which I then want to center and make the cell unevaluatable. Doing that requires typing RACCPV.

<alt>RACCPV

It would be nice to program a hotkey for that.

Reading past efforts to "Macrofy" Mathematica, it appears that the choice is between "FrontEndExecute" and a ResourceFunction "AddMenuItem" both of which are daunting. I do not want to modify the front end and foul up all my other Mathematica activities. Presently I am regularly pasting a graphic into a notebook which I then want to center and make the cell unevaluatable. Doing that requires typing RACCPV. It would be nice to program a hotkey for that.

Reading past efforts to "Macrofy" Mathematica, it appears that the choice is between "FrontEndExecute" and a ResourceFunction "AddMenuItem" both of which are daunting. I do not want to modify the front end and foul up all my other Mathematica activities. Presently I am regularly pasting a graphic into a notebook which I then want to center and make the cell unevaluatable. Doing that requires typing

<alt>RACCPV

It would be nice to program a hotkey for that.

Source Link
Rogo
  • 950
  • 4
  • 11
Loading