Autosave Only after Text is edited?


hi have below script from.  working great wondering if there way make activate if text has changed (being added or deleted etc..). added event listener , function doautosave{}.  version have "for test" set activate before save.  eventlisteners not working. no matter eventlistener have in there saves document opened whether change has been made or not.

 

 

#targetengine "saveevery1mn"    app.addeventlistener( "beforesave", doautosave ); function doautosave(){  main();    var filter = function() {     var w = "indesign files:*.indd;",     m = function(f) {return /\.indd$/.test(f.name); };   return $.os[0]=="w"?w:m;   }   function main() {     var t = (new date()).gettime();     var onidleeventhandler = function(idleevent) {     var doc = app.properties.activedocument;   if ( !doc ) return;   if ( !doc.properties.fullname ) {     var f = file.savedialog("you need save document !", filter);   if ( f ) {     doc.save ( f );     }   return;     }     var t2 = (new date()).gettime();   if ( t2-t > 1000 )  {     t = t2;     doc.save();     }     }     var myidletask = app.idletasks.item("autosave");   if ( !myidletask.isvalid ) {     myidletask = app.idletasks.add({name:"autosave", sleep:100});     myidletask.addeventlistener(idleevent.on_idle, onidleeventhandler, false);     }   }   }  

i provided script months ago able detect stories changes can display "real time" characters count. if find post see how can merge them both.

loic



More discussions in InDesign Scripting


adobe

Comments

Popular posts from this blog

Illustrator CS6 Ocurrío un error E/S en el archivo.

Animate - problem with duplicating scripts after loop

Why is os_ViewContainer running?