Manipulating the Front End from the Kernel

$FrontEndthe front end currently in use
Options[$FrontEnd,option]the setting for a global option in the front end
AbsoluteOptions[$FrontEnd,option]the absolute setting for an option
SetOptions[$FrontEnd,option->value]reset an option in the front end
CurrentValue[$FrontEnd, option]return option value, and also allow setting of option when used as the left-hand side of an assignment

Manipulating global options in the front end.

Just like cells and notebooks, the complete Mathematica front end has various options, which you can look at and manipulate from the kernel.

This gives the object corresponding to the front end currently in use.
In[1]:=
Click for copyable input
Out[1]=
This gives the current directory used by the front end for notebook files.
In[2]:=
Click for copyable input
Out[2]=
option
default value
NotebookBrowseDirectory(system dependent)the default directory for opening and saving notebook files
NotebookPath(system dependent)the path to search when trying to open notebooks
Language"English"default language for text
MessageOptions(list of settings)how to handle various help and warning messages

A few global options for the Mathematica front end.

By using NotebookWrite you can effectively input to the front end any ordinary text that you can enter on the keyboard. FrontEndTokenExecute allows you to send from the kernel any command that the front end can execute. These commands include both menu items and control sequences.

FrontEndTokenExecute["name"]execute a named command in the front end

Executing a named command in the front end.

"Indent"indent all selected lines by one tab
"NotebookStatisticsDialog"display statistics about the current notebook
"OpenCloseGroup"toggle a cell group between open and closed
"CellSplit"split a cell in two at the current insertion point
"DuplicatePreviousInput"create a new cell which is a duplicate of the nearest input cell above
"FindDialog"bring up the Find dialog
"ColorSelectorDialog"bring up the Color Selector dialog
"GraphicsAlign"align selected graphics
"CompleteSelection"complete the command name that is the current selection

A few named commands that can be given to the front end. These commands usually correspond to menu items.

New to Mathematica? Find your learning path »
Have a question? Ask support »