Notification Script Issues
I am using a variation of @Russ Ward 's 06.01 Notification script from here: http://www.weststreetconsulting.com/WSC_ExtendScriptSamples.htm
I want the script to run a second script when a document is first opened and when the active document changes.
Right now, the script just shows some confirmation dialogs, instead of running the other script. Here is the script:
Notification(Constants.FA_Note_PostActiveDocChange, true);
Notification(Constants.FA_Note_PreQuitSession, true);
function Notify(note, object, sparam, iparam)
{
switch (note)
{
case Constants.FA_Note_PostActiveDocChange:
// alert("The active doc changed");
var doc = app.ActiveDoc;
if (doc.ObjectValid()){
var returnVal = confirm("The active doc changed: \n\nDo you want to keep receiving this notification?");
if(returnVal == 0)
{
Notification(Constants.FA_Note_PostActiveDocChange , false);
}
}
break;
// win.close
case Constants.FA_Note_PreQuitSession:
Notification(Constants.FA_Note_PostActiveDocChange , false);
Notification(Constants.FA_Note_PreQuitSession , false);
alert("closing script");
break;
}
}I'm running into the followings issues:
- The PostActiveDocChange notification seems to fire when I first open FM, even though there is no active doc. I tried to work around that with my "if" statement above, but it didn't seem to work. That's a minor annoyance for the confirmation statement, but for the script I want to launch, it is going to show an error message about not having an active document and needing to quit, so I want to avoid that.
- Related, if instead of closing Framemaker, I close the last document that was open, I also get the message, even though there is no active document. This will cause a similar error.
- The PostActiveDocChange notification seems to fire twice when I open a file, then it works normally. Minor issue. My script closes all open user-palettes (pop-up windows) and opens a new one. So when first opening a document, the pop-up is going to appear, close, and re-open - probably look like flicker. Not a big deal, but not ideal either.
- Originally, I had an issue with the script staying active even after I closed and re-opened FrameMaker. The PreQuitSession notification seems to handle that. Originally, I tried post-quit session and that didn't work.
Thanks in advance!!!
