Zack Lovatt

Behance Bitbucket Dribbble LinkedIn Skype Vimeo
May 11, 2017

Extendscript Toolkit: Setting default document text

Posted In: scripting

When I use ESTK, I always want to start with the same foundation, setting up an IIFE so I can play and not fuck with AE/ESTK global scope. For this example, the snippet below is what I want to start with.


(function () {

})();

Note: This involves editing ESTK Required files. Edit at your own risk!

These files are located here on Windows:
C:\Program Files (x86)\Adobe\Adobe ExtendScript Toolkit CC\Required


Method 1: Prepopulate temp file on Startup

01startup.jsx, line 246

If you only want to set up default text when ESTK starts up, on a blank document, use this method.

Replace this:


if( docwin && docwin.docObj )
docMgr.activateDocument( docwin.docObj );

With this:


if( docwin && docwin.docObj ) {
docMgr.activateDocument( docwin.docObj );
docwin.docObj.setText(“(function () {\n\t\n})();\n”, false);
}


Method 2: Prepopulate ‘new file’:

61fileMenu.jsx, line 33

If you want to set up default text when creating a new document (via File => New, or Ctrl+N), use this method.

Replace


menus.file.newFile.onSelect = function()
{
if( app.modalState ) return;
docMgr.create();
}

With

menus.file.newFile.onSelect = function()
{
if( app.modalState ) return;
docwin = docMgr.create();
docwin.docObj.setText(“(function () {\n\t\n})();\n”, false);
}


Method 3: Prepopulate global ‘new document’ action

78documentmanager.jsx, line 91

This goes further upstream – any ‘new document’ action (such as opening ESTK, or making a new file) will now be prepopulated with your snippet. Broadest option.

Replace


if( !text )
text = “”;

With

if( !text )
text = “(function () {\n\t\n})();\n”;

0 Comments

Would you like to share your thoughts?

Leave a Reply