Detect 3dsmax exit/close program

Is there a way to detect when max is closing (exiting) so that my script that runs in background can write some data to file before max closes?
I'm making script that will log work hours, so I will want to be able to write to file when max has closed...

I have made if so far in way that logs work time every 10 min, and it detects if you have opened new file, so it starts new count down for new file.
But it will be more elegant if I will be able to detect when someone closes max, so that I can just write down when file/max was opened and closed...
Currently, it's not a problem if you open max, work on one file, then open next one; it writes info for first file, but for last file, it just writes when file was opened, but not when it was closed... Or if you worked on just one file...

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

functions names

I see funtion naming mistake. You define 'test_fn' but try to register undefined function 'test_function'.

my recent MAXScripts RSS (archive here)

koberko's picture

sry, it's a my mistake; I

sry, it's a my mistake; I typed wrong here in topic; in actual script they are named correctly...
Both are named "test_function"
Here is complete code:

macroScript work_time_test
category: "Berko scripts"
tooltip: "work time"
buttontext: "Time"

(
fn test_function = (print "testing, testing")
callbacks.removeScripts id:#berko_fn
callbacks.addScript #filePreOpenProcess "test_function()" id:#berko_fn
)

P.S. When I add code to callback it self, then it works; for example:

callbacks.addScript #filePreOpenProcess "format \"Scene closed at: %\n\"localTime to:out_file"

But I can't (don't know how) call function that was defined above callback,with that callback...
Please, tell me what I'm doing wrong...

Anubis's picture

Global!

Make your function global to be visible.

my recent MAXScripts RSS (archive here)

koberko's picture

tnx!

tnx!

koberko's picture

Tnx for info...But as usual,

Tnx for info...
But as usual, one solution leads to new problems...
I didn't quite understand how to call some function with callbacks;
for example, this is in help file:

callbacks.addScript #preRender "setUpRenderGeom()" id:#jbwRender

- This registers a new callback script that will be called just before a render is performed. The script invokes a function (that has presumably already been set up). A unique ID has been assigned to the script for later selective removal.

And I try to did something of my own like this:

fn test_fn = print "testing, testing"
callbacks.addScript #filePreOpenProcess "test_function()"

and I get this error:
-- Error occurred in anonymous codeblock; filename: none; position: 0
-- Frame:
-- test_function: undefined
>> MAXScript Callback script Exception: -- Type error: Call needs function or class, got: undefined <<

Anubis's picture

callbacks

Search for "callbacks" into mxs-help, then in "General Event Callback Mechanism" topic read "System Notifications" section.

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.