Copy link to clipboard
Copied
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.
If you need another instance of After Effects that doesn't interrupt your user's actions in the current instance, then use the -m flag:
AfterFX.com -noui -m -s "alert('test')"
or
AfterFX.exe -noui -m -s "alert('test')"
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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:
-d | Don'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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
This is really ***ing me off too. One tolerable solution is to drag corners of AE window to just near edges so it is almost maximized, then when sending script it will stay in this "restored" position. Not ideal. Can't believe there isn't a command that can be sent via cmd.exe to simply maximize a running instance of a window.
Copy link to clipboard
Copied
Ahhh - and just found out if you do that via placement of the window and then ctrl +\ to hide the titlebar, then AE will occupy a maximized position when firing a script at it from somewhere else... that works. Win 7 64 - AE CC 2014.
Copy link to clipboard
Copied
Hey adobe_sur2,
I would like to know if you have found a solution yet.
Thanks.
Copy link to clipboard
Copied
Still... but that doesn't really solve the problem, does it? I am fighting with this issue as well.... Still no solution, other than check the state of the window before running a command, then run the command, and then force set the window to the same state... haven't tried it yet, but in theory it should work, though the movement of the window will probably be visible.
Copy link to clipboard
Copied
I came up with basically what you suggested using AutoHotkey and a keyboard shortcut. Here an example Autohotkey script:
#1:: ;Shortcut combination is Windows key + 1
{
WinGet, minmax_state, MinMax, A ;Gets current Min/Max state of active window
Run AfterFX.exe -r scriptfile.jsx ;runs script
if minmax_state = 1 ;if window was previously maxmized
{
Sleep, 100 ;sleep so script is at least starting to run
WinMaximize, A ; maximizes active window
}
Return
}
There's a visible restoring and then maximizing back like you predicted but it's pretty quick.
You do need Autohotkey installed, although you can super easily convert an Autohotkey script to an exe file (just right click script file -> compile) if you need to move it around.
Not sure how it'll work with slow scripts - sleep might need to be slightly longer.
Still - not a solution, just a workaround
Copy link to clipboard
Copied
It's been a little over a year since the last update here.
Has anyone figured this out? I'm running into this same problem while trying to write tools that interact with our shot tracking system at our studio.
This "restoring" of the window basically makes this unusable because artists don't want their windows to be changing sizes while they are working.
Has anyone from Adobe weighed in on this to explain the strange behavior when calling afterfx.exe from command line?
Copy link to clipboard
Copied
VertigoJC What are you trying to do with this background function? Can you use aerender.exe instead? (also, might wanna start a new thread on this topic)
Copy link to clipboard
Copied
If you need another instance of After Effects that doesn't interrupt your user's actions in the current instance, then use the -m flag:
AfterFX.com -noui -m -s "alert('test')"
or
AfterFX.exe -noui -m -s "alert('test')"
Copy link to clipboard
Copied
We are developing a standalone "sidekick" app that integrates with our shot tracking database. I want to use the command line to call scripts with -r or run some code with -s to update existing variables in AE or to fire off certain scripts to notify artists of changes in their project. That part of it all works except for the fact that AE gets knocked out of maximized mode when it is called from the command line, which is incredibly frustrating for the artist working on it.
Copy link to clipboard
Copied
CLI commands are best suited for standalone operations like batch/procedural rendering and such. What you're describing would be much easier achieved through a persistent script or invisible CEP extension that can communicate with your external app via WebSockets.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now