The following example demonstrates how to register a MAXScript event handler that will react when Windows System settings are being changed.
CODE:
``` --First we need the SystemEvents DotNet Class: c = dotNetClass "Microsoft.Win32.SystemEvents" -->dotNetClass:Microsoft.Win32.SystemEvents --Then we get a list of all available events: showevents c -->[static] DisplaySettingsChanged
sender e = ( ... ) -->[static] DisplaySettingsChanging sender e = ( ... ) -->[static] EventsThreadShutdown sender e = ( ... ) -->[static] InstalledFontsChanged sender e = ( ... ) -->[static] LowMemory sender e = ( ... ) -->[static] PaletteChanged sender e = ( ... ) -->[static] PowerModeChanged sender e = ( ... ) -->[static] SessionEnded sender e = ( ... ) -->[static] SessionEnding sender e = ( ... ) -->[static] SessionSwitch sender e = ( ... ) -->[static] TimeChanged sender e = ( ... ) -->[static] TimerElapsed sender e = ( ... ) -->[static] UserPreferenceChanged sender e = ( ... ) -->[static] UserPreferenceChanging sender e = ( ... ) -->true --We define a global function to be called by the event handler: fn TimeChanged a1 a2 = format "TimeChanged callback: % : %\n" a1 a2 -->TimeChanged() --Finally we add the Event Handler for the event "TimeChanged": dotnet.addeventhandler c "TimeChanged" TimeChanged -->OK
```
Now, if you open the Date and Time properties of MS Windows, change the seconds only (to avoid problems with your 3ds Max license, do not change the date too much) and apply the changes. The MAXScript function we registered will be called and will print in the Listener:
TimeChanged callback: dotNetObject:Microsoft.Win32.SystemEvents : dotNetObject:System.EventArgs
As you can see from the events list, you can register event handlers to be notified when display settings are being changed, the palette or fonts are changing, and so on.