Keyboard Shortcut several Keys

I would like to set up a system (or define a keyboard shortcut) so when you type the following


I have the following print at the current selection.

ToBoxes[Unevaluated@Sum[Placeholder[ ], {t, 1, n}]],

This only works partially works b/c it removes focus.

x = Input[“”]




Unless you want to do it in Mathematica for you own specific reasons (portability maybe), I would strongly recommend Autohotkey? The pain you have to go through for that simple task is not worth the effort in Mathematica. In Autohotkey, that task is a one-liner: ::sum::Sum[Placeholder[ ], `{t, 1, n`}]{Left 5}
– Hector
Sep 3 ’14 at 6:21



What would be the easiest way to run a M Function? Or how might I Print a ToBoxes version? Autohotkey doesn’t seem to
– Liam
Sep 3 ’14 at 12:22


2 Answers


Try this:

nb = CreateDocument[{},
InputAliases -> {“sum” ->
“\!\(\*UnderoverscriptBox[\(\[Sum]\), \(\[Placeholder] = \
\[Placeholder]\), \(\[Placeholder]\)]\)\[Placeholder]”}];

After evaluation a new notebook opens. Type in this notebook: Esc+sum+Esc. Done. Have fun!



I have been reconsidering my original thought if it is really a good idea but you definitely deserve and up vote.
– Liam
Sep 8 ’14 at 22:37



@Liam William The up-vote is no matter. The point is that there are lots of already existing hot keys. I use some of them and there are too many to memorize them all. You might want to check Menu/Help/DocumentationCenter/tutorial/EnteringTwoDimensiona‌​lInput. Otherwise if you open any panel, such as Menu/Palette/BasicMathAssistant or Menu/Palette/SpecialCharacters and hover the cursor over any button you will find the corresponding hot key below the palette. In particular, Esc+sum+Esc gives you the sum by itself without additional efforts. So it may be a good idea to check already existing keys
– Alexei Boulbitch
Sep 9 ’14 at 8:04



This should work pretty well if I combine it with an Autohotkey scriptw
– Liam
Sep 9 ’14 at 23:09

After thinking it through some more this is the best solution I have come up with so far
is to run the following in Mathematica so you can paste code into Mathematica that has formatting

“DuplicatePreviousOutput”, {Delimiter,
MenuItem[“Raw Paste Clipboard”, FrontEnd`KernelExecute[

Catch[NotebookGet@ClipboardNotebook[] /.
Cell[r_, ___] :> Block[{}, Throw[r, tag] /; True];
$Failed, tag], Placeholder]

], MenuKey[“v”, Modifiers -> {“Control”, “Shift”}],
System`MenuEvaluator -> Automatic]}]]

Next you can create Autohotkey scripts like the following

clipboard =
\*SubsuperscriptBox[\(\[Sum]\), \(i =
1\), \(\[Placeholder]\)]\[Placeholder]\)
Send, ^+v