Run a script by clicking on a button panel

Hello

I am very new scripting in after effects and in general.
Several months ago I write several small scripts to speed my work flow. I have run it through the "Launching pad" script Panel.
Now, I have my scripts in my own panel but miss me properties to bind the part "script" and the "part of the group.

For the Panel, I have (just one button for now):

---------------

win = new window ('window', 'new project', [0,0,500,500], {Center:true,});})

but_1 is Win.Add ("Button", [33,16,103,36], "Sharpen3Way");.

Win.Center ();

Win.Show ();

------------------

and my previous script that operate independently.

----------------

myComp = app.project.activeItem;Select the composition active

app.beginUndoGroup ("sharpness 3 Way");Starting group Undo

mySolid01 = myComp.layers.addSolid ([100,100,100], "Whet", myComp.width, myComp.height, 1);   Layer of United Nations Adds solid

mySolid01.adjustmentLayer = true;En transforms the solid layer of setting
mySolid01.label = 5;Sets the color of a layer of setting
mySolid01.opacity.setValue (40);Change the opacity of the layer

myEffect = mySolid01.property("Effects").addProperty ("Unsharp Mask") .name = "Unsharp Mask wide";Adds an effect on this layer

myEffect = mySolid01.Effects.property ("Unsharp Mask Large") (1) .setValue (10);

myEffect = mySolid01.Effects.property ("Unsharp Mask Large") (2) .setValue (40);

myEffect = mySolid01.property("Effects").addProperty ("Unsharp Mask") .name = "Unsharp Mask Medium";Adds an effect on this layer

myEffect = mySolid01.Effects.property ("Unsharp Mask Medium") (1) .setValue (65);

myEffect = mySolid01.Effects.property ("Unsharp Mask Medium") (2) .setValue (1);

myEffect = mySolid01.property("Effects").addProperty ("Unsharp Mask") .name = "Unsharp Mask Fine";Adds an effect on this layer

myEffect = mySolid01.Effects.property ('Unsharp Mask Fine') (1) .setValue (95);

myEffect = mySolid01.Effects.property ('Unsharp Mask Fine') (2) .setValue (0.5);

app.endUndoGroup ();Dispose of end group

---------------------------

How the relationship to run the script, when I click on the but_1 ("Sharpen3Way")

Thank you.

Hello

If you have a lot of paperwork and they are short like that, you can turn them into functions and in, click events, the function is called.

A little off topic but I think it is important, to (1) avoid type windows showcase, pallets are better, (2) you must use the keyword "var" in the declaration of new variables,

(3) to make attachable take a look at the tutorials from David Torno ([tutorial] after effects ExtendScript written Script).

Edit: And also (4), you must use matchNames (or index) return to properties, not English name. If you give this script to someone who doesn't have an AE I English, this probably will not work

For example myEffect should be instead: myEffect = mySolid01.property("ADBE_Effect_Parade").addProperty ("ADBE blur Mask2");

Xavier.

(function(){

    var win, but_1, but_2;

    win = new Window("palette","new project",[0,0,500,500],{resizeable:true,});
    but_1=win.add("button",[33,16,103,36],"Sharpen3Ways");
    but_2=win.add("button",[33+100,16,103+100,36],"Sharpen0Way");
    but_1.onClick = sharpen3Ways;
    but_2.onClick = sharpen0Way;
    win.center();
    win.show();

    function sharpen3Ways(){

        var myComp, mySolid, myEffect;

        // Selectionne la composition active
        myComp = app.project.activeItem;

        if (myComp instanceof CompItem){
            app.beginUndoGroup("Sharpen 3 Way");                  // Start Undo Group

            // Ajoute un layer Solid
            mySolid01 = myComp.layers.addSolid([100,100,100], "Sharpen", myComp.width, myComp.height,1);
            mySolid01.adjustmentLayer = true;                                                                                                      // Transforme le Solid en Adjustement Layer
            mySolid01.label = 5;                                                                                                                            // Attribue la couleur d'un Adjustement Layer
            mySolid01.transform.opacity.setValue(40);                                                                                                          //  Change l'opacité du Layer

            // Ajoute un effet  sur ce calque (unsharp mask)
            myEffect = mySolid01.property("Effects").addProperty("Unsharp Mask");
            myEffect.name = "Unsharp Mask Large";
            myEffect(1).setValue(10);
            myEffect(2).setValue(40);

            // Ajoute un effet  sur ce calque (unsharp mask)
            myEffect = mySolid01.property("Effects").addProperty("Unsharp Mask");
            myEffect.name = "Unsharp Mask Medium";
            myEffect(1).setValue(65);
            myEffect(2).setValue(1);

            // Ajoute un effet  sur ce calque (unsharp mask)
            myEffect = mySolid01.property("Effects").addProperty("Unsharp Mask");
            myEffect.name = "Unsharp Mask Fine";
            myEffect(1).setValue(95);
            myEffect(2).setValue(0.5);

            app.endUndoGroup();                // End Undo Group
            }
        else{
            // ignore or send some alert
            };
        return;
        };

    function sharpen0Way(){
        alert("About to do something, ... dont know yet what.");
        };

    return;
    })();

Tags: After Effects

Similar Questions

  • Send the setting click on the button (panels)

    Hello world

    I'm currently trying to create a dockable panel on AE with ExtendScript, and I have a problem when I create the buttons.

    the thing is the number of buttons and their callbacks is not resolved and is sent to the script via a socket connected to a python interpreter.

    This part works well, according to what I have sent on the socket, AE creates buttons more or less.

    The problem comes when I have to click on the buttons. For now, I use this:

    function createUI(thisObj)
              {
                        myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "test panel", [100, 100, 300, 300]);
                        var panelstr = "myPanel.";
    
    
                        for(var i=0 ; i < commands_lenght ; i++)
                        {
                                  var cmd_name = commands_name[i].Name;
                                  cmd_name = cmd_name.replace(/\s+/g, '');
                                  cmd_name = cmd_name.split('.').join("");
                                  var cmd = panelstr.concat(cmd_name);
                                  button = eval(cmd);
    
    
                                  var posb = 5 + 25*i;
                                  var pose = posb + 20;
                                  button = myPanel.add("button", [0, posb, 100, pose], commands_name[i].Name);
                                  button.onClick = testclicked;
                        }
    
    
                        return myPanel;
              }
    
    
              function testclicked()
              {
                        alert("you clicked, well done! \nwant a medal?");
              }
    
    

    or is that what I would like to send a parameter to the function being called when (onClick)

    something like that:

    function createUI(thisObj)
              {
    
                                  button.onClick = testclicked(parameter);
              }
    
    
                        return myPanel;
              }
    
    
              function testclicked(parameter)
              {
                        alert("you clicked the" + parameter + " button, well done! \nwant a medal?");
              }
    
    

    and so far, it has not worked.

    so I wonder if it is still possible to do ^^'

    Thanks in advance for your answers

    Justin

    You cannot add an argument to a reminder.

    What are you trying to do exactly? The problem is that I do not understand what should be the variable 'parameter.

    If you need to use a specific variable within your callback you could just add to your variables button, I have not tried but it doesn't work?

    
    button1.onClick = testclicked();
    button1.myParameter = "first";
    
    button2.onClick = testclicked();
    button2.myParameter = "second";
    
    function testclicked()
    {
        alert("you clicked the " + this.myParameter + " button, well done! \nwant a medal?");
    }
    
  • Can I run an action on click of a button in Acrobat?

    Hello world

    I created some actions in acrobat to perform certain operations on most of the PDF files. To run or activate action, I must always go into tools-> Action Wizard and perform the action. I want to run this action to a button click event. Is it possible to perform an action on a button click event or if it will be javascript code? Please help me in this regard. I use Acrobat X PRO.

    Thank you

    Manjeet

    Hello world

    I've studied a lot of things and come to the conclusion that it is not possible to run/activate an action on any type of event (or using javascript).

    Another point action cannot run another action in Acrobat X pro.

    Kind regards

    Manjeete

  • Running a script to simulate a mouse click on a point

    Hi all

    I am facing some problems while trying to use a plugin red giant (Trapcode Sound Keys), via a script running on a server.

    That the plug-in has an "Apply" button that generates keyframes based on the song of the imported file. However, I can't seem to be able to trigger this button via a handful or whatever it is, giant red support told me that it was not any information about it as their plug-in was not really intended for this use.

    So the question became more general, is it possible to run a script on the AE to simulate a mouse click on the button?

    Or someone has an idea in a different way? I'm really open to any suggestion, even through the SDK.

    Thank you all for your time,

    Kind regards

    Juan

    Mouse events can be performed on ScriptUI elements ExtendScript scripts, not AE plugins. P. 153 of the Javascript Tools Guide CC.pdf

    The only way to trigger the button apply to this plugin is to click top manually through user interaction.

  • How to run a script from a "Button 1" button?

    Hi all, I had this problem to have a window with several buttons named "Button 1" "button 2"... and run the script 'Script A' If you click on button 1, the script 'Script B' If you click on the button 2, etc... ".

    Here is my small script:

    indesign #target

    create a table of contents that send directly to the good script

    var l = new Window ("dialog");

    var buttongroup = w.add ("group");

    var panel = buttongroup.add ("panel");

    var button1 is panel.add ("button", undefined,"Script");.

    var button2 is panel.add ("button", undefined, "Script B");.

    var button3 is panel.add ("button", undefined, "Script C");.

    var cancel = buttongroup.add ("button", undefined, "Cancel", {name:'cancel'});})

    buttongroup.addEventListener ('click', press)

    w.Show ();

    function press (e) {}

    {if(e.Target.type=="Button")}

    If {(A e.target.text is "Script. »)

    w.Close ();

    app.doScript (new File("c/scriptA.jsx"),ScriptLanguage.javascript);

    }

    Else if (e.target.text == "Script B") {}

    app.doScript (new File("c/scriptB.jsx"),ScriptLanguage.javascript);

    }

    Else if (e.target.text == "Script C") {}

    app.doScript (new File("c/scriptC.jsx"),ScriptLanguage.javascript);

    }

    }

    }

    Each manuscript A, B and C starts with an app.dialogs.add)

    And that is the problem, he said that an alert or a modal dialog box is already active

    I tried the w.close (), but it does not work...

    I don't think that addEventListener is what I need, maybe I'm wrong for a window, but it is the only way to give names to the buttons, is it not?

    Instead of var this:

    w = new Window ("dialog");

    Use this:

    var l = new Window ("range");

    Peter

  • animation continues to run through. I want that he stop on main menu, so I can click on the buttons

    animation continues to run through. I want that he stop on main menu, so I can click on the buttons that navigate to different scenes. Please help me I'm a noob.

    Here are screenshots of what I have in progress:

    Screen shot 2013-09-06 at 1.25.57 PM.png"Home" menu of the main time line

    Screen shot 2013-09-06 at 1.27.22 PM.pngscript in frame 1

    Screen shot 2013-09-06 at 1.27.57 PM.pngscript in frame 48

    Screen shot 2013-09-06 at 1.30.50 PM.pnganimation scene 2 shape tween who is not supposed to work at the long past the homepage. I want to animate but only after I click the button to do it.

    Screen shot 2013-09-06 at 1.30.58 PM.pngscript for this scene

    Screen shot 2013-09-06 at 1.31.12 PM.pngstage 3, which is causing all the issues I think? supposed to be able to drag the boxes. but it passes right through without stopping when I play.

    This is the compiler errors:

    Screen shot 2013-09-06 at 1.43.07 PM.png

    If you deleted the stop() of scene 2, that it will not stop there it will return to wherever is 'home '.

    If you intend to have the timeline stop on an image, then you must place a stop() command in this frame, or use a gotoAndStop() command.

    If you want to use the scenes be compatible with the way you write the goto command. Is rarely recommended use - instead, use the various sections of the chronology of a scene, or use some movieclips and control their visibility, or a combination of both.

    If you continue to have problems, try to simplify - build / add first navigation for a section at a time instead of trying to get all of a sudden.

  • ScriptUI run the script in the button of the dialog box

    Here's what I have right now.  It's a little awkward in the way it works, and I just have a little smoother.

    I have a script at startup which creates a Menu item with a submenu of the menu item drop-down. When you click the submenu item, it runs a script.

    The first thing the script is pop up a message box that tells them that two dialog boxes go to the pop-up window. One by asking them to choose the location of an xml file and the second dialog box that ask them to choose the location of their folder of images.  After you finish choose their folder in the second dialog box, the script takes these two values, makes variable and continues to run the rest of the script.

    Here's what I would...

    1. open a window for dialogue with two input fields, both 'Browse' buttons and OK and CANCEL buttons

    2. When you click Browse next to the first input box for the first button, it will open a file dialog window.  You select your file and the file string will populate the input field

    3. When you click on the second button next to the second entry field, it opens a file dialog window.  You select the file and the string fills the second input field.

    4. When you click OK, it nurtures values in the input to a script fields.

    I already have scripts which opens the dialog for file and folder boxes, but what I can't understand how the is to start and run a script to a button press, in this case, when you press the OK button.  It's probably an onClick, but I was not able to find examples of what would be the syntax.

    Is the closest I found in the beginning ScriptUI document that was on the site of Jongware, in the section on Communication between the windows.  But each window opens with a different scenario and is not using a button to call a script.

    As always, any point in the right direction is much appreciated. Thank you.

    ScriptUI windows and JS file dialog boxes are not communucate. To get a return value in a file dialog box, you would do something like this:

    myFile = file (myFolder) .openDlg ("select files");

    If (myFile = null)

    back, do nothing

    The JavaScript Tools Guide CSx (see the Help menu on the ESTK) documents several dialogues selection of files and folders.

    Peter

  • Show/hide an element with the click of a button - Script works does not in Firefox

    Hi all

    Basically, I'm looking for show/hide a DIV with the click of a button.

    The script works in IE but fail in FF.

    I am sure that I am the problem here.

    <script type="text/javascript">

    function toggle(box) {
         var el = document.getElementById('box');
         el.style.display = (el.style.display != 'none' ? 'none' : '' );
         
         
         value = document.getElementById('content').value;
         if(value=="Show Calendar"){
         document.getElementById('content').value="Hide Calendar";
         }
         else{
         document.getElementById('content').value="Show Calendar";     
    }
    }
    </script>


    <style type="text/css">
    #box{
         background-color: #C0C0C0;
         height: 100px;
         width: 100px;
    }
    </style>
    </head>

    <body>

    <div id="box">
    </div>

    <input id="content" value="Hide Calendar" type="button" onclick="toggle(box)" />
    </body>
    </html>

    WE

    He also worked if you had changed-

    
    

    on this subject.

    
    
  • How to run the PL SQL function on click of a button

    Hello

    I have problem with run SQL PS function on click of a button. I have create a new button and call the function STANJA.insert_into_log_fun1('cc'); "Value of the button application", a Type of Source select button request = 'SQL PL Expression or function.
    Problem is that this function is executed at the loading of the page, but not to the click. I don't want to perform this function on loading the page, only when I click the button.

    Does anyone have idea how can I solve this problem?
    Thank you very much.

    Alter this process > status > when you press the button > choose the button you want the pcoss to run on.

    RAL

  • How to run the SWF file when I click on a button

    Dear friends!

    I did three and kept SWF files in a folder, how do I make a flash 8 project to execute when I click on a button. I'm going to make buttons for each SWF file

    Please help me

    use loadMovie to load in your main swf (with button).

  • TypeError: try to run the script compilation and go on a 'mistake' in scope cleared when message returns the transfer through images for each image. Does not affect viewing.

    TypeError: try to run the script compilation and go on a contour

    Above the error message appears when moving between images - back and forth. By clicking on the OK button removes the error message and there is no apparent problem. The window that appears refers to a JAVA Script Application (I guess that FIREFOX is the application?)

    -> Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems

    Check and tell if its working.

  • Access error of data while running the script in the script fdm workbench Editor

    Hello Experts,

    I get the error when I run the script in the script of fdqm established client.this editor is the error

    -2147467259 data access error and he navigates the error on line 30 on this script «Set rsAppend = DW.» DataAccess.farsTable (strWorkTableName).

    Please return me asap where I should charge peoplesoft data to one of my database of planning through fdm.

    Thanks in advance...

    You will need to build a script for integration that is an import Script that allows you to import data from SQL in FDM.

    When you create your import format, you will need to configure it with the file Type = Script and then assign the script of integration as an Expression. Assign your import format to the location that you use to import data.

    Then you can test it by going to the import stage and clicking the import button. FDM will run the integration script and data import by running the SQL query that you have defined.

    To the contrary, "Data Pump" import Scripts are used as import expressions in the import formats

    You can run a script to integrate the customer that this script requires input parameters that are passed only when then FDM import step is executed. If you want to see the raised error open the errorlog FDM. You will only be able to run this Workbench script when you want to debug data is being extracted, but in this case, you will need to comment code that inserts the data in the table. Don't forget that the work table is a temporary table that is created when you click on the import button and if you run Workbench this table does not exist

  • Issue size PDF after click on the button "Save as".

    Hello everyone, I have a pdf file that is about 180 KB.

    After clicking on a button "save under", that I created, a small calculation script is run and the file, after registration, jumps to 1, 2Mb.

    Any thoughts on how to avoid this? Javascript calculations are simple calculations (capital plus interest and a penalty).

    Thank you everyone for the help!

    This is usually caused by policies that have been added to your form fields.

    You use a non-standard font?

  • Running a script?

    Sorry for the really basic question but I can't seem to find an answer (and I promise you that I looked at).

    Ive got a script for the bridge of ps - scripts.com which takes the file name and it will be on title, or any other party declared metadata metadata (if I can use live captions in Indesign without seeing the file extension).

    However, I don't have the slightest idea how to run this script in bridge.

    Everything I've seen says it's a bridge script not a photoshop script, or they work in the same way?

    For any reference to the script http://www.PS-scripts.com/BB/viewtopic.php?f=18 & t = 2406 & sid = abb69282c947bc40ec10% 2081d5c7b9 a6fc #p10283 .

    See you soon.

    Bridge CS5 (4.1.0.54). Windows 7.

    In goto Bridge preferences - Startup Scripts

    Click below button "reveal", this will open the folder where the script should be placed in a text file with the .jsx extension.

    Close and restart Bridge.

    Accept the new script.

    The script is now ready to run in the Tools menu.

  • How to access a script or plugin via a button?

    Hello world!

    Does anyone know if it is possible to access, add or open another script or plugin through a button?

    It's because I bought a very useful script on http://aescripts.com/ , called UN-precompose Batch image Software (http://aescripts.com/un-precompose/). My idea is now to create a button where I can access this script / plugin through simply by clicking a button on a GUI. This because I not then go to layer-> UN-precompose whenever I'm going to use (it's often!).

    The file is a. AEX file and the script / plugin are under the layer menu of AE.

    United Nations-precompose is also installed under the file-> plugins folder support

    Good answer:

    Run the plug-in:

    David Torno

    http://forums.Adobe.com/message/5833529#5833529

    Run the script from script:

    var file = new file ('/ c/Program Files / Adobe / Adobe After Effects CS6/SupportFiles/Scripts/_Your_Script_.jsx');

    leader. Open ("r");

    eval (file. Read());

    leader. Close();

    }

Maybe you are looking for