I'm working on a program that will run as a separate process but will interact with MediaMonkey. The intent is for the script to have no UI of its own. I would like to allow the user to stop my program on demand by putting a Terminate script in the Tools|Scripts menu.
The problem is, there is no good API for signaling my program. I'm really only looking for a boolean flag that I can set within the MM script, and read, then reset, from within my program; or else a message that I could somehow send. But there is no general-purpose inter-script communication. I have tried setting a value in SDB.Objects(), which works to signal my program but my program can't reset the value of what gets returned -- because the COM model exposes SDB.Objects() as a method rather than as an object reference.
Something like Script.Terminate would seem to be ideal, but that's really designed to end scripts running with MM, and anyway I don't see how to set it from a script.
I could do something hacky like create a temp file or set a registry key from the script, which I would then monitor from within my program, but that's really not very elegant. I could create a channel, such as a named-pipe, to allow me to send the message, but that's a lot of work for a simple one-off communication. I could also simply tell the user to kill the process, which is not dangerous in my case but doesn't allow a clean shutdown.
My current workaround, which is a total hack but simple, is to have the Terminate script set the ComServerUIActive flag to True, then monitor that with my program; when it goes True, the program resets it to False and terminates. But that's not what that flag is used for; I can only get away with it because it's such an obscure value that neither MM or any other add-on is likely to be making use of it. (I don't need to use it as it's intended because I monitor the Shutdown message in my program.)
What I would like is a general-purpose Script.Data() technique where any script could set data with a particular key. For my purpose, simple boolean data would be sufficient (i.e., Script.GetFlag(name) and Script.SetFlag(name, value)), or even a generic event (i.e., SDB.Broadcast(message) which would trigger an "OnBroadcast" COM event).


