Put this file in the Adobe startup scripts folder. It's based on a more complicated script I wrote for a client, but it will do what you asked for, and more:ĭropbox - spellCheckMonitor.jsx - Simplify your life Rather than try to fix your script, I will offer an example. Your engagement letter must've gotten lost in the mail. Then your beforeClose event listener could check to see if the current user has employed spellcheck even if a previous user did it earlier. So your confirm message could say things like: "You have not used spell check on this document" or "The last time you spell-checked this document was [time and date from the script label." If you have more than one designer working on the same documents, you should be able to get the userID from the system variables and store that info in the script label too. Rather than ask your designer if he/she has used spellcheck, the beforeClose function will be able to read the script label to find out if spellcheck has been used and, if so, when. Then, use the afterOpen listener described above to attach a beforeClose listener to each LayoutWIndow. Its function will be to record the date and time in a script label for the document. It is possible to add even more functionality to this: FIrst, attach an "afterInvoke" listener to the spell-check menu item. Each beforeClose listener is destroyed when the window closes, but it will already have executed your confirm(). The afterOpen listener runs throughout your session, attaching beforeClose listeners to all of the LayoutWindows you open. In this way, you never have to remove either event listener. If the target is a "LayoutWindow" a "beforeClose" listener is attach to that window. I suggest that you employ two event listeners: The first, attached to the application, listens for the "afterOpen" event. But then, as Manan points out, you can't remove the event listener if you want it to run on every document. If you test for the event.target, you will be able to display your alert only when the LayoutWindow opens. You didn't say what went wrong with the afterOpen event, but one common problem is that it fires twice when you open a document: The first target will be the document and the second will be the LayoutWindow. The other issue is that you are blindly removing the event handlers, think of the situation where the app has some handlers added by some other scripts, your code will then break other scripts as well In my opinion you should just do nothing in this case. ![]() Now the other issues with your code is that when the user clicks on Yes you remove all the eventlisteners added on to the app, do you really need this? This would mean that once the user clicks yes your code would never be called again as you have removed the event listener. ![]() This code will also fail if your are using a non english version of InDesign as it would not have the menu displayed in english, to be safe you should use the menu string as $ID/Check Spelling. ![]() I am not sure why you are getting the error, which version of InDesign are you using? Might be possible that your version of InDesign does not have the menu with the name "Check Spelling." but rather it is present with another name. This code works fine for me, and pops up the spell check dialog when i press no on the prompt dialog.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |