WOLFRAM LANGUAGE TUTORIAL
Front End Tokens
Front end tokens let you perform kernel commands that would normally be done using the menus. Front end tokens are particularly convenient for writing programs to manipulate notebooks.
FrontEndToken is a kernel command that identifies its argument as a front end token. FrontEndExecute is a kernel command that sends its argument to the front end for execution. For example, the following command creates a new notebook.
FrontEndExecute can take a list as its argument, allowing you to execute multiple tokens in a single evaluation. When you evaluate the following command, the front end creates a new notebook and then pastes the contents of the clipboard into that notebook.
Simple and Compound Front End Tokens
Front end tokens are divided into two classes: simple tokens and compound tokens that take parameters.
For simple tokens, FrontEndToken can have one or two arguments.
If FrontEndToken has one argument, the token operates on the input notebook. The following examples use the front end token "Save". The result is the same as using .
With two arguments, the arguments of FrontEndToken must be a NotebookObject and a front end token. For example, to save the notebook containing the current evaluation, the first argument of FrontEndToken is the notebook object EvaluationNotebook , and the second argument is the front end token "Save".
You can execute a simple, one-argument front end token with the command FrontEndTokenExecute[token]. This is equivalent to FrontEndExecute[FrontEndToken[token]].
For example, the following command will save the input notebook.
Compound tokens have a token parameter that controls some aspect of their behavior. For a compound token, the three arguments of FrontEndToken must be a NotebookObject, the front end token, and the selected token parameter.
For example, this saves the selected notebook as plain text.