Hi Peer,
re:
> Is there a way that a script running in one instance of MoI can determine what
> files are open in all other running instances? Like getting
> moi.geometryDatabase.currentFileName from each of the other instances?
Sorry no there is not any built in facility set up for scripts to do that.
The file name is set on the window title though, so it is probably possible that a helper app written in Swift or Obj-C could enumerate windows looking for titles that end in "- MoI" and harvesting the name preceding that.
Then you could call the app from script in MoI using moi.filesystem.shellExecute( Path, Params, WaitForFinished );
If WaitForFinished = true, there is an object returned that contains properties for .exitCode (numeric process exit code value) and .output (text written to std out for the executed process).
> How about switching windows using a script? Can I get a script running in one
> instance to switch to the window of another instance?
There isn't any way for a script to directly trigger that but if you can get a keystroke generated somehow, Cmd+~ and Cmd+Shift+~ will switch to prev/next windows.
If you can get the pid of the one you want to switch to then the objective-c code for bringing it to the front is like this:
code:
NSRunningApplication* pApp = [NSRunningApplication runningApplicationWithProcessIdentifier:pid];
if ( pApp )
[pApp activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];
- Michael
|