Trigger When Process Complete

You can trigger a macro from a script as described in the Scripting section of the documentation, or as described on this thread