Run a script by clicking on a button panel

Hi,
i am very new to scripting in after affects and in general.
Several month ago i write severals little scripts to speeds up my workflow. I launch them via the "Launch Pad" script Panel.
Now, i would like to put my scripts in my own panel but i'm missing the properties to link the "script part" and the "panel part".
For the panel i have (just one button for the moment):
win=new Window("window","new project",[0,0,500,500],{resizeable:true,});
but_1=win.add("button",[33,16,103,36],"Sharpen3Way");
win.center();
win.show();
and  my previous script that work independently.
myComp = app.project.activeItem;
// Selectionne la composition active
app.beginUndoGroup("Sharpen 3 Way");              
// Start Undo Group
mySolid01 = myComp.layers.addSolid([100,100,100], "Sharpen", myComp.width, myComp.height,1);   // Ajoute un layer Solid
mySolid01.adjustmentLayer = true;                                                                                             
// Transforme le Solid en Adjustement Layer
mySolid01.label = 5;                                                                                                                   
// Attribue la couleur d'un Adjustement Layer
mySolid01.opacity.setValue(40);                                                                                                  
//  Change l'opacité du Layer
myEffect = mySolid01.property("Effects").addProperty("Unsharp Mask").name = "Unsharp Mask Large";  
// Ajoute un effet  sur ce calque 
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";
// Ajoute un effet  sur ce calque 
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";    
// Ajoute un effet  sur ce calque 
myEffect = mySolid01.Effects.property("Unsharp Mask Fine")(1).setValue(95);
myEffect = mySolid01.Effects.property("Unsharp Mask Fine")(2).setValue(0.5);
app.endUndoGroup();            
// End Undo Group
How do i make the relation to run the script when i click on the but_1 ("Sharpen3Way")
thanks you.

Hi,
if you don't have that many scripts and they are short like this, you can make them into functions, and on click events the function is called.
A bit off topic but i think important, (1) avoid windows of type window, palettes are better, (2) you should use the keyword "var" when declaring new variables,
(3) to make it dockable have a look at David Torno's tutorials ([Tutorial] After Effects ExtendScript Script Writing).
Edit : And also (4) You should use matchNames (or index) to refer to properties, not english name. If you hand this script to someone who does not have AE i english, it will probably not work
For instance myEffect should be instead: myEffect = mySolid01.property("ADBE Effect Parade").addProperty("ADBE Unsharp 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;

Similar Messages

  • Run time error when clicking on sum button

    Hi,
        I have used a field (data type-QUAN,length-10,Decimal Places-3)
    in an internal table. I have passed this table in 'REUSE_ALV_GRID_DISPLAY'.
        When I wan to see the 'sum' by clicking the button on the application tool bar , There is always a run time error.
        Please help as quick as possible.
    Regards,
    Sourav Paul.

    Hi,
    try following,
    DATA: GT_EVENTS TYPE SLIS_T_EVENT.
    INITIALIZATION.
    PERFORM BUILD_EVENTS CHANGING GT_EVENTS.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
               IT_EVENTS          = GT_EVENTS[]
        TABLES
          T_OUTTAB           = IFINAL.
    ENDFORM.                    " display_output
    FORM BUILD_EVENTS CHANGING GT_EVENTS TYPE SLIS_T_EVENT.
      DATA: LINE_EVENT TYPE SLIS_ALV_EVENT.
      CLEAR LINE_EVENT.
      LINE_EVENT-NAME = 'TOP_OF_PAGE'.
      LINE_EVENT-FORM = 'TOP_OF_PAGE'.
      APPEND LINE_EVENT TO GT_EVENTS.
    ENDFORM.                    "build_events
    Reward pts if usefull.
    Regards,
    Dhan

  • On using search engine i found an error message:Warning Mozilla Firefox is running. Exit and click the Retry button... I restarted my computer but got the same problem

    please help me with the above problem

    See:
    * https://support.mozilla.com/kb/Firefox+is+already+running+but+is+not+responding

  • Cannot run calc script from Analyzer

    I just did an upgrade from 6.5 to 6.5.1 and I am unable to run one calc script on a particular database. I can run other calc scripts, just not this one. I get no error message or anything, I can keep clicking the calc button, but it does not run.Strangely, when I click the calc button, Analyzer puts a text file in the directory \\analyzer\appserver\bin with the user name (ex. gcrisci.txt) When you open this file, it is the calc script from Essbase I was attempting to run.I recall running into a problem like this in the past due to the size of the calc script. I thought the solution was to go into Analyzer.properties file and increase the MaxDataCellLimit values. The default is 50000, I've increased it up to 500000 with no resolution. So, I'm thinking maybe this isn't the fix.Does anyone know of a solution to this problem?Thank you.

    John,
    Here are the roles that i assigned my user and he can view/launch the calc scripts from Planning Web without actually being an admin( i think)
    Analytic Servers : server access
    Business Rules: Administrator
    Planning App : Interactive User
    APS : Provisioning Manager
    I would also like to conver the calc script to a BR as suggested, but not sure why i see no users available in the Business Rules-> administration tab.
    As indicated above, the use has been provisioned as a BR admin!
    Also, i tried refreshing the app with filters, refreshing the user list from BR->admin(right mouse), de-provision and re-provision the user! Any ideas??

  • Click a button to run a script

    hi, I'm runnning Solaris server, create a Java GUI application. I want to achieve the following task:
    1) Once I click on the button on the Java GUI application, the application will invoke a script written in perl. (in this sense, the button acts a bridge to run the perl script)
    Any one know how to achieve this, using what Java classes to run scripts written by other scripting language?
    Thanks in advance:)

    To execute other stuff (such as perl scripts), use Runtime.exec(String command). Check the API documentation for details.
    (I think you are confusing yourself and setting up for bad design by dragging the button into the "how to run a script"-part of it, but that's another issue.)

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

    Hi all, I've got this problem for having a window with several buttons named "Button 1" "Button 2"... and run the script "Script A" if we click on the button 1, the script "Script B" if we click on the button 2 etc...
    Here is my short script :
    #target indesign
    //make a table of contents which send directly to the right script
    var w=new Window("dialog");
    var buttongroup=w.add("group");
    var panel=buttongroup.add("panel");
    var button1=panel.add("button",undefined,"Script A");
    var button2=panel.add("button",undefined,"Script B");
    var button3=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(e.target.text=="Script A"){
                //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 script A, B and C begins with an app.dialogs.add()
    And here is the problem, it tells me that an alert or a modal dialog is already active
    I tried the w.close() but it doesn't work...
    I don't think addEventListener is what I need, maybe I'm wrong for using a window but it's the only way to give names to the buttons, isn't it ?

    Now I get it... I work both on Mac and Windows but when I tried the 'palette' I forgot that I had only the version CS4 on Windows
    (and I launched the script from the ESTK instead of the script panel..mistake !!)
    Now it works great on the Mac, thank you Peter for the help and for the pdf scriptui

  • Run PLSQL code by click on button usin javascript

    Hi
    I want to run plsql code
    on click button using javascript
    javascript is ok but code of plsql is not run
    suggest me
    APEX 4.2.1
    Oracle !!XE
    Windows Server
    Firefox 17.0.1
    Theme Cloudy
    thanks in advance
    bUTTON CODE IN PLSQL CODE AND SEND_RMNDE IS PROCEDURE
    '<button type="button" name="button1" onclick="send_rmndr('
    ||NO_DUES_MASTER.CERT_ID
    ||');" value ='
    ||NO_DUES_MASTER.CERT_ID
    ||'> '
    ||'Remind'
    ||'</button>'
    JAVASCRIPT
    <script type="text/javascript">
    function send_rmndr(pThis)
    var params='x= '+pThis;
    var get=new htmldb_Get(null,null,null,&APP_PAGE_ID.,null,'send_reminder',params);
    gReturn = get.get();
    //alert(gReturn);
    alert ('inside script ' +params);
    //get=null;
    </script>
    Edited by: 969091 on Feb 1, 2013 9:13 PM

    send_reminder needs to be defined as an application process
    Alternatively, you can define a dynamic action and do this more declaratively.
    It's easy to define a DA that fires on click of a button that runs PL/SQL, and you can also define which page items are sent to and received from the plsql via session state.
    Scott
    blog: [url grassroots-oracle.com]grassroots-oracle.com
    twitter: [url twitter.com/swesley_perth]@swesley_perth
    -- please mark any useful posts as helpful or correct, in the end it helps us all

  • I get a window pop up after every click into a new site that reads : Safari is no longer responding because of a script on the webpage "    ". Do you want to stop running the script, or let it continue? If I  click on continue it just continues,

    I get a window pop up after every click into a new site that reads : Safari is no longer responding because of a script on the webpage "    ". Do you want to stop running the script, or let it continue? If I  click on continue it just continues, stop, it stops.  How to correct this annoying message?

    Disable Javascript for those webpages.  Note, your Javascript is probably antiquated by now.  Try a different web browser, or contact the website and let them know they aren't as accessible as they could be*:
    http://www.macmaps.com/browser.html

  • Why is the battery life dropping so fast on my iphone 4s. Just started all of a sudden today, never did it before. I already double-clicked the bottom button to see what was running and nothing was running. I checked multiple times and turned apps. off.

    All of a sudden today my battery life just started dropping off on my iphone 4s. I charge it every night. I double clicked the circle button on the bottom to see what was running and there was minimal running but i turned them off anyway. I checked back in a little bit, the same, turned the couple things off again which were like phone and messages... nothing major running. Battery percentage still plummeted til it just turned off.

    Are there apps on your phone right now? 
    I think one of your apps is causing this.
    The only way to find out is to delete them all and then add them one by one to see what app maybe causing this.
    Especially if you've gone thru 3 iphones already.
    When you restored as new - did you sync back your stuff - apps/music or did you restore from backup?

  • Running abap reports in the background when clicked on Webdynpro Button

    Hi Experts,
    I have requirement where when clicked on a Button in a Webdynpro application, it needs to run an abap reports in the background and I need to pass some parameters to the report.
    Is it possible to do that? if yes, please guide me though.
    Reward points for useful tips.
    Sabbir
    Edited by: Sabbir Ahmed on Oct 17, 2008 8:05 AM
    Edited by: Armin Reichert on Oct 24, 2008 10:05 AM

    you can use rfc's model  for this na?
    pass the parameters to the RFC and through that RFC run the report,
    with regards
    shanto aloor.

  • How to run a plan (once and only once) by clicking on a button ?

    Hi all,
    I've been using Oracle BAM 10.1.3.3 on a project and my customer is now asking for the following feature:
    He would like to manually launch a plan (once and only once) by clicking on a button of a web page.
    In my opinion a possible way of implementing this scenario is:
    create a new alert which "Event" set to "When this rule is launched" and Action set to "Run a Plan". In addition I should copy the alert URL and paste it on the page, anytime the final user clicks on that link the alert will be launched and the plan will be run.
    Is that correct? Otherwise could you please give an advice?
    Thanks a lot in advance for your help.
    BR Fabio

    Hello there!
    There are lots of online resources available at www.ni.com that will be able to help you, as well as the available resources in LabVIEW such as the LabVIEW Help and the Find Examples options under the Help tab.
    Obviously, none of these will do the whole project, but will be relevent for different parts of it.
    The link to the online LabVIEW manual is here and the part most relevant to yourslf when starting a block diagram is here.
    As a guideline, the examples are a very very useful guide on good-practice programming as well as problem solving and introducing you to the different functions available.
    Another very useful link is the NI Developer Zone, from where you will be able to access Tutorials on thousands of features.
    I hope this helps!
    Liam A.
    National Instruments
    Applications Engineer

  • HT4623 How do I close apps running in the background....I have tried double clicking the home button and then the swiping up and it does not work???

    I just updated my phone and can not close the running apps. Battery dying fast. I did try double clicking the home button but swiping up did not work??

    With iOS 7, swiping the application thumbnail up the screen does close the app.

  • HT201365 Before I downloaded the iOS 7 upgrade I could turn off the apps that were running in the background by double clicking the bottom button to bring up the apps. I would hold down on 1 app, X's would appear on each and then I could close them. How N

    Before I downloaded the iOS 7 upgrade I could turn off the apps that were running in the background by double clicking the bottom button to bring up the apps. I would hold down on 1 app, X's would appear on each and then I could close them. How Now?

    and
    Because my first response would be....Oh, sure.....
    Because I am sorry you are having a hassle with the intenet. There is nothing more frustruating than having to deal with a slow response, or a makeshift connection....hope it gets fixed soon!!!
    Your friend,
    GB

  • In mail 8.2 if I click the template button the CPU start running at 150% CPU and WindowServer arrive to 20 GB and more of memory

    hello, after upgrade to Yosemite I have a problem with Mail/CPU.
    if I create a new email message everything is ok, but if I click the button at the top right (show template) on the message window, the CPU running at 130-150% and the VirtualServer memory start increasing up you 20 GB and more.
    If I close and reopen Mail (without closing the mail message) the CPU return to 130-150% but if I send or delete the message the CPU return to the standard value
    If I don't click the template button on the new message window the CPU works correctly.
    This thing cause slowdowns and unexpected logout of my imac, I contacted applecare twice and they told me to create a new user (first) and reinstall a fresh operating system (second). I have done both but the problem is not solved.
    I have also tried this (without results): Guide: How to solve Yosemite memory leaks and CPU usage
    Do you have any solution for may problem?
    imac 5K - 16 GB ram
    Yosemite 10.10.2
    Mail 8.2
    Thanks in advance

    I have that same problem on all my yosemite Mac´s too and no solution yet exept deleting your own templates.
    But if you need to use the templates for your business like i do this is not an "good" option
    I use this workaround at the moment until theres a fix
    You can copy our own templates in an existing nativ template folder apple mail uses. (Google knows where the folders are)
    (Or you can use another Mail program or a slow Apple Mail )

  • I run DeviceDemo sample to send email, when click send email button after f

    I run DeviceDemo sample to send email, when click send email button after filling all fields, it took me to EverNote application, can not send email. does anyone has this kind experience? how to fix it?

    Hi,
    ADF Mobile cannot directly send emails as this is a security precaution of your mobile phone (imagine all applications could send mails without you confirming). Instead the send mail functionality launches the mail client you have configured and fill in the information you provided in the application. The mail function by the way is implemented through Cordova.
    Frank

Maybe you are looking for

  • Connecting to a video projector

    I bought a projector and cable, but instructions are unclear. They say "You must find the 'FN' key on your keyboard, and you must also find another key that looks like a square computer screen." I can fn the FN key, but not the other. Is there some k

  • No mail visible in Web, but visible in client

    Hi, One user has a strange problem. When using Web Access he has no mail in the "Inbox". The "Cabinet" and "Sent Items" are ok. The little "thermometer" in the right hand corner show 27% utilisation. If I use the client, I can see all his mail .....

  • FCPX or Premier?  Ouch

    2 years ago, our non-profit organization started producing videos for broadcast on our local NBC affiliate.  Two professional mentors (both in our town, both do major national work, one is a multi-million dollar company) told us to use FCP7 (or they

  • This is my Jsp code for image upload in database:

    This is my Jsp code for image upload in database: -----------Upload.jsp---------------- <html> <head> </head> <body bgproperties="fixed" bgcolor="#CCFFFF"> <form method="POST" action="UploadPicture.jsp" enctype="multiform/form-data"> <%! int update=0

  • Question about converting trial to full version.

    Hi there, I have 2 questions: 1. Currently I am using Framemaker 7.2 trial version. I have the licence code for Framemaker 7.2. I found out from the Adobe website (http://www.adobe.com/support/service/trial.html) that I need to Activate the trial pro