Skip to main content
Known Participant
August 30, 2010
Question

Prevent Document close by close(x) using startup Script

  • August 30, 2010
  • 2 replies
  • 1086 views

Hi,

     Im developing a startup script to control of document close using the close(x) icon of the document.can anyone help me???

This topic has been closed for replies.

2 replies

tomaxxi
Inspiring
August 30, 2010

Hey!

It's possible to disable closing document.

Try this:

#targetengine disableItems

var disableClose = app.activeDocument.eventListeners.add("beforeClose", stopMenuEvent);
function stopMenuEvent(stopMenuEvent){
    alert("Sorry, you can't close this document!","Closing disabled!");
    stopMenuEvent.stopPropagation();
    stopMenuEvent.preventDefault();
}

Hope it helps!

This works just with CS5.

--

tomaxxi

http://indisnip.wordpress.com/

Jongware
Community Expert
Community Expert
August 30, 2010

Yes, that traps Close in the File menu ... but does it also work with the box? (Sorry -- no CS5 nearby, otherwise I'd just try it.)

tomaxxi
Inspiring
August 30, 2010

Yes, it does. If even catches application close.

--

tomaxxi

Jongware
Community Expert
Community Expert
August 30, 2010

It's not possible to control windows components through scripting.