Copy link to clipboard
Copied
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:
Thanks in advance!!!
Resolved - although a bit of an odd solution.
I had the script set to autorun so I could see what happened when you first opened FrameMaker before a document was active.
I unregistered the script and re-loaded it and I was seeing the I'm here messages.
I had to remove the script from auto-run and re-enter if for the changes to take effect. Apparently, FM was using the previous version of the script and not re-opening it from the saved version on the hard drive like I would have expected.
With th
...Copy link to clipboard
Copied
It could be that the Welcome window is seen as a document. Try displaying the document's Label property and see what it says.
Copy link to clipboard
Copied
I have the welcome window turned off, but I guess I should account for that for others.
I added " alert(doc.label);" after the if (doc.ObjectValid) statement, but I never saw anything display. Also added "alert("I'm here!") and nothing displayed.
I'm going to try to re-boot and see what that does.
I've used doc = app.ActiveDoc forever - probably from some of your scripts - LOL!!!
Copy link to clipboard
Copied
One other thing to note; this is unnecessary:
var doc = app.ActiveDoc;
The object parameter will be the new active document (Doc) object, so you can use this:
var doc = object;
Copy link to clipboard
Copied
Reboot didn't help. But something is wrong with my script, b/c I should at least be seeing the "I'm here" alert message.
Copy link to clipboard
Copied
Resolved - although a bit of an odd solution.
I had the script set to autorun so I could see what happened when you first opened FrameMaker before a document was active.
I unregistered the script and re-loaded it and I was seeing the I'm here messages.
I had to remove the script from auto-run and re-enter if for the changes to take effect. Apparently, FM was using the previous version of the script and not re-opening it from the saved version on the hard drive like I would have expected.
With the updated version of the script, I don't get the notification when FM first starts up nor when the last document closes. So there isn't a valid current document at that point.
Apparently, FM thinks that the active document changes when the last open document is close (which somewhat makes sense), and when the program first opens and there is no active document - which doesn't really make sense.
I guess the double prompt when opening a file (still happens), is the same type of thing, the current active document is closing, and the new one is opening.
But odd that if I switch between open documents, I only get one prompt.
Copy link to clipboard
Copied
> I had to remove the script from auto-run and re-enter if for the changes to take effect. Apparently, FM was using the previous version of the script and not re-opening it from the saved version on the hard drive like I would have expected.
Scripts are loaded into memory at FrameMaker startup so any changes you make won't be picked up until you restart FrameMaker. You can bypass this by running the script after making changes so that a fresh copy gets loaded into memory.
Copy link to clipboard
Copied
@ frameexpert :
>Scripts are loaded into memory at FrameMaker startup so any changes you make won't be picked up until you restart FrameMaker. You can bypass this by running the script after making changes so that a fresh copy gets loaded into memory.
That was what I would have expected, not what I was seeing. Changes were not picked up when I restarted FM. Changes were not picked up when I re-booted the PC. Changes were not picked up until I removed the script from autorun and re-added it to autorun.
Not sure why ...
Find more inspiration, events, and resources on the new Adobe Community
Explore Now