6 Replies Latest reply: Apr 15, 2014 12:29 PM by adobe_sur2 RSS

    afterfx command line "restores" maximized window - any way to duplicate ExtendScript invocation?

    adobe_sur2 Community Member

      Hi all,

       

      I am controlling After Effects CC from another application by invoking JavaScript files from the command line. But the command *always* restores the maximized window of After Effects. That is, if the After Effects application is maximized, it always *restores* it, every time I invoke the JavaScript file through the command line (e.g. through Windows cmd prompt or through my application). When I execute the same JavaScript file through ExtendScript IDE, it doesn't do this erronous behaviour.

       

      For example: "AfterFx.exe -r C:\path\showDialog.jsx"

       

      Contents of showDialog.jsx:

      ----------

      alert("Showing Dialog from JSX file");

      ----------

       

      My question is: Is there *any way* to mimic what ExtendScript does to invoke JavaScript files?

      From listening on Windows processes, it seems that ExtendScript tacks on some JavaScript code, dynamically, to do the execution (i.e. couldn't trace any command line processes/arguments). But I can't seem to figure out what exact JavaScript code it invokes. ExtendScript also seems to be working via Bridge.

       

      I get the same "restore window" behaviour when I try to use "-s" argument with the JavaScript expression passed as a string argument or if I use "AfterFx.com" instead of "AfterFx.exe". I couldn't find any documentation for what command line parameters are supported for AfterFx (other than "-r" and "-s") and what Extend Script might be doing exactly to invoke the .jsx files. I managed to take a peek at the executable binary of AfterFx.exe (through a hex editor) and noticed the following switches.

      -rquiet, -noerr, -noui, -debug, -livelink, -selflink, -headlessonly, -rquiet, -rq, -mp

       

      But I couldn't get the "window restoring" behaviour to stop with any of the parameters.

       

      Any advice will be really appreciated.

       

       

      Thanks.

        • 1. Re: afterfx command line "restores" maximized window - any way to duplicate ExtendScript invocation?
          Arie Stavchansky Community Member

          If you use the -noui switch you shouldn't see the UI at all.  Your script requires AE to show an alert dialog so it probably won't work though.  Try making your script do something other than alerting the user and see if the problem persists.

          • 2. Re: afterfx command line "restores" maximized window - any way to duplicate ExtendScript invocation?
            adobe_sur2 Community Member

            Hi again,

             

            Thanks for the comment. I was using the "alert" command just as a example but I did try it with other scripts which doesn't show a dialog message, with the "-noui" argument. The result is the same. I tried several combinations with "-noui", "-rq" and "-rquiet".

             

            For example, here is one script which increases the frame duration: AfterFx.exe -r C:\path\frameDuration.jsx

            --

             

            Content of frameDuration.jsx:

            --

            var currFrameDuration = app.project.activeItem.frameDuration;

            app.project.activeItem.frameDuration = currFrameDuration + 0.01;

            --

             

            Also, note that even if I don't put any argument and just execute AfterFx.exe (from the command line or from the start menu), the behaviour is the same - that is, if the After Effects application was maximized, it restores the window to the last known window which wasn't maximized. So I am wondering whether this is just how they coded AfterFx - to restore the window if the executable is launched while the application is still running. But if that is the case, I don't know how to control After Effects with scripts, from my own desktop application. If I put a script in the startup folder and use the Socket object to listen on a port for commands (from my desktop application), then it freezes the After Effects UI completely. I think I read somewhere that ExtendScript uses Bridge talk protocol to execute JavaScript files from the IDE. But I can't seem to find details as to how my desktop application can replicate what ExtendScript does to execute JavaScript files.

             

            Thanks.

            • 3. Re: afterfx command line "restores" maximized window - any way to duplicate ExtendScript invocation?
              Arie Stavchansky Community Member

              Have you tried using something like PsExec to lauch AfterFX.exe?  There are a good number of switches you can use there to handle how the process is launched.  Also, maybe try to use Windows' command interpreter (cmd) to launch AfterFX.exe in the background.

               

              Check out PsExec here:

              http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

               

              --Arie

              • 4. Re: afterfx command line "restores" maximized window - any way to duplicate ExtendScript invocation?
                adobe_sur2 Community Member

                Hi,

                 

                Thanks again for your comments. I tried with PsExec just now but no luck still. The only useful argument parameter in PsExe seems to be:

                 

                -dDon't wait for process to terminate (non-interactive).

                But the same behaviour happens. I tried with "-e" as well (separately and combined with "-d").

                 

                I also tried a few command line argument options with "start" command, on the Windows Command prompt. For example:
                "start /MAX AfterFx.exe -r C:\path\file.jsx" <-- supposed to start the application in the maximized state

                "start /b AfterFx.exe -r C:\path\file.jsx" <-- supposed to start the app without a creating a new window

                 

                But no luck still . Tried various combinations of the above two arguments as well.

                 

                 

                Seems like Adobe After Effects explicitly does something weird to snap the application *out* of the MAXIMIZED state, if the executable is invoked (either via command line, with or without arguments or directly from start menu/GUI items). I don't know why they would do this though. I also wonder whether this is simply a bug in their implementation of Adobe After Effects CC on Windows 7.

                 

                Is there any way to MAXIMIZE Adobe Effects Effects through their JavaScript API? I am wondering whether I can explicility check/set the window to be maximized in my invoked script, to fix this behaviour.

                 

                Thanks.

                • 5. Re: afterfx command line "restores" maximized window - any way to duplicate ExtendScript invocation?
                  Arie Stavchansky Community Member

                  Sorry PsExec didn’t work out for you.  The only thing I can think of for handling the AE window is using the application object.  There is a app.activate(); command that “Opens the application main window if it is minimized or iconified, and brings it to the front of the desktop.”  Does that help?

                   

                  —Arie

                  • 6. Re: afterfx command line "restores" maximized window - any way to duplicate ExtendScript invocation?
                    adobe_sur2 Community Member

                    Yah, I did try a few of those things to explicitly MAXIMIZE the Adobe After Effects instance. But no luck.

                     

                    * AfterFx.exe -s "app.activate()" <-- just brings the app to the front of all the windows (even if minimized), it is not already the case. But the same issue exists if the app is maximized; it restores it back to the last known restore position. It does

                     

                    I also tried :

                     

                    * AfterFx.exe -s" app.activeViewer.maximize = true" <-- this sets the internal "viewer" to be maximized, within the bounds of the entire application. But this doesn't maximize the application itself. The same issue exists where the AfterFx application snaps the window out of the maximized state and puts it into restore state. I can't see any JavaScript attributes or functions to modify application level MAXIMIZE state.

                     

                    I wonder if there is any other Windows specific command line way of *setting* an application to be maximized, after it has already been launched.

                     

                    Thanks.