Max Console Clear

Christian Haines's icon

Hi Folks.

Max console clearing via keyboard shortcut has come up often as a feature request. Some solutions have been offered via a series of shortcuts, Apple Script, snippets etc. Below is my take on it (haven't seen this on the forums.. correct me if I'm wrong!). Tested on MacOS (12.6) only.

In short, I created a patcher called "Max Console Clear". Added a loadbang, ";max clearmaxwindow", and some window commands to hide / close the patcher window, placed it in the "Extras" folder and then use the OS to create a custom shortcut to the patcher. The shortcut launches the patcher, clears the Max window and then closes. Hopefully all that can be seen is a brief loss of window focus.

To open the patcher loadbang needs to defeated using File then Open while holding Cmd + Shift. When the patcher has been opened (with loadbang defeated) a short cut (Alt/Opt + H) can be used to assist viewing and editing the contents.

Best,C

Max Console Clear.maxpat
Max Patch

Source Audio's icon

Why don't you add entry in maxinterface.json file
to clear max console using a shortcut ?

bd's icon

Wow, Source Audio, that sounds brilliant! I did not know that file at all ;)
Where did you put it exactly? I tried adding a shortcut, restarted Max, nothing happens though. Could not find any reference in documentation.
{
"message" : "maxclearall",
"label" : "Clear All",
"shortcut" : "F4",
"target" : "owner",
"icon" : "revert.svg",
"caption" : "Clear All"
},

Source Audio's icon

I am not sure if that can work, because command maxclearall
is bound to max concole window itself - that toggle at bottom left.
I don't think one can add shortcut for that.

I used new menu item for that if I remember correctly (was in max 5)
and used clearmaxwindow message.
something like
{
"message" : "clearmaxwindow",
"label" : "clear",
"target" : "max",
"shortcut" : "<"
},

That had to be referenced in max menubar by adding id for it.

bd's icon

Perfect, that works. Thanks a lot!
Now I only must find out what exactly means:
- max: extra arguments for message "clearmaxwindow" -
because that is what gets posted every time after the console is cleared when I use the shortcut.
I did not figure it out yet.
That is the block now, I see no extra arguments...
{
"message" : "clearmaxwindow",
"label" : "clear",
"target" : "max",
"shortcut" : "F4"
}

Anyway thanks a lot!


Source Audio's icon

i don't remember getting that errors, but at that time I used that
on standalone app, and at the end wiped maxwinow completely,
and reduced json file to bare minimum.

it could be some internal max error as it does not expect to receive control messages from the menubar.


bd's icon

That would be awesome to have some proper reference what messages can be send that way etc.
For now, at least until I find out more, either I live with that one error and working global shortcut - or use the shortcut added to the "maxclearall" message. The max window must be in focus though in that case:
{
"message" : "maxclearall",
"label" : "Clear All",
"shortcut" : "F4",
"target" : "owner",
"icon" : "revert.svg",
"caption" : "Clear All"
},

Both ways are an improvement anyway :)

Source Audio's icon

If maxclearall works, could you also add same F4 shortcut to
bring maxwindow to front and wipe it at same time ?


Christian Haines's icon

Wow. Thanks for that suggestion SourceAudio. I've followed the suggestion / conversation you and BD have had, and got it working. Same issue with "max: extra arguments for message "clearmaxwindow" and couldn't find a solution. Obviously when the message is executed an argument is being bound to it that it doesn't need and there doesn't appear a way to remove it.

I've noted a few other points:
- a few messages from the maxinterface.json work directly with the message box using ";max <message>". e.g. ;max showclue - like you said BD, it would nice to have a reference on what works.
- when using the maxinterface.json all shortcuts for MacOS (except F keys) appear to be bound with the command prefix (⌘) e.g. Shift + H becomes Shift + ⌘ + H. Also meaning that shortcuts without the command prefix (e.g. shift+option+C) don't appear possible unless using a system level shortcut setting.

Source Audio's icon

If you really get so disturbed by that error message

one can remove it....

shown max 8.1.11 Mac

Friendly Coder's icon

Hey :))

This sounds very interesting, but i cant seem to find this maxinterface.json file anywhere. Where is it located?

cheers

Christian Haines's icon

On MacOS 15 it's within the application bundle. As for Windows, I'd assume a similar location but can't confirm that. Cheers.