Redirecting Listener output to another window


Wandering by maxscript listener properties and methods I accidentally stumbled on .SetEchoWindow which is .net version of set_echo_window of IWindowStream interface
All it is doing is sending any listener output using WM_SETTEXT to another window.
Maybe somebody find it useful one day

rollout X "" ( )
createDialog X
l = (dotNetClass "Autodesk.Max.GlobalInterface").Instance.TheListener
l.editstream.SetEchoWindow (dotNetObject "System.IntPtr" x.hwnd)

for i = 1 to 5 do ( print i; sleep 0.25 )


I think it would be very useful if listener could text string to a file ,such as log , as max crashed so frequently while debugging


there’s a openLog function, although I never used it
openLog <filename_string> [ mode: "w" | "a" ] [ outputOnly:<boolean> ]


I used it a lot and it does work. Just have to add flushLog() frequently.


I never tried it before , and i will try when i get a new crash file
I worked for a farm , and I should debugging script to compatible with from 2010 to 2023 , lots of files crashed before logs output , it’s hard to get what was happened , especially 2013 and 2014 files , lots of them are degraded form a natural file in higher version


On the contrary, I get output text from max listener handle and send it to vscode terminal.
The editor of max is very difficult to use. vscode makes me happy.:person_fencing:


Can you tell a little about how to send it?


Vscode can execute an custom exe file, in which you can use Console.WriteLine(C#) to output the content, and then you can get the content in vscode.

As for exe, you can use win32 to get handle, get text, etc.


yeah, I know. I’ve built a tool that sends script to max.
So you somehow wait until the script is finished execution and then grab the output from the listener and write it to the console which in turn goes into vscode terminal, right? Pretty smart



Code Runner enables you to execute exe better
multi-command can configure shortcut keys (get the same feel as max editor)