Extendscript "Hello World !!!"

Hello.





I want to offer you a small example that will help a beginner with a quick start in writing scripts for Adobe programs . This script is for After Effects . If you are not familiar with the program itself, this is not a big deal, basic knowledge of javascript will be enough. You can find the full script with comments here .





So, let's begin.





Our little plugin (technically not a plugin, but let's call it that) will be a window in the AfterEffects interface, in which you can write a script and execute it right there. Agree, this should be convenient for a beginner. Since this is an interface window with its own context, we will place all its code inside an object:





{
	//     
}
      
      



The first thing we need to do is create a window or, if it has already been created, get a link to it.





{
      var win = (this instanceof Panel)
          ? this
          : new Window("palette", 'Extendscript Notepad');
}
      
      



this instanceof Panel, win . new Window("palette", 'Extendscript Notepad') . Window . , . , , . 





. .









var editText = win.add(
   'edittext',                 
   [0, 0, 300, 300],           
   'alert("Hello, World!!!")',
   { multiline: true }
);
      
      



add . :





  • , 'edittext' 









  • ,









, 0 0 , 300 * 300 , 'alert("Hello, World!!!")' , , ( ). 





.





, .





var btnRun = win.add(
   	'button',
   	undefined,
   	'run'
);
      
      



, undefined , .





, . onClick





btnRun.onClick = function() {
   try {
       eval(editText.text);
   } catch (e) {
       alert(e);
   }
};
      
      



eval(editText.text). - , alert(e);





. , .





win.layout.layout(true);
win.onResizing  =
win.onResize    = function () {
   this.layout.resize();
};
win.layout.resize();

if(win instanceof Window) {
   win.show();
}
      
      



!!! . .jsx . AfterEffects. . File -> Scripts -> Run Script File . , alert("Hello World!!!"). run .





As a joke, I inserted the code of the plugin itself, and each subsequent button click opened a new instance of it.





You can find all the Extendscript documentation here .





Descriptions of interface elements are well described here and here .





Good luck! Go for it!





Next article: Extendscript Working with Files ->








All Articles