By evaluating some Mathematica commands, I wish to get the equivalent effect as selecting Delete All Messages on the message window.


You can obtain the NotebookObject corresponding to the messages window using MessagesNotebook, and then delete all the cells using NotebookDelete:

NotebookDelete @ Cells @ MessagesNotebook[]
  • $\begingroup$ Thank you very much indeed ! $\endgroup$ – MiuraB Jul 19 '19 at 6:21

You can also do what the button in messages notebook does:

    FrontEndToken[FrontEnd`MessagesNotebook[], "SelectAll"], 
    FrontEndToken[FrontEnd`MessagesNotebook[], "Clear"]

The advantage is that it may not require kernel to run at all because all symbols are known by the front end. So this will work:

Button["test", (*our code*), Evaluator -> None ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.