Ep. 02 runMenuCmd Free Function Friday
Hi there and welcome to Free Function Friday. So, are you looking for an easy way to just simply launch a menu command? Like “New Comp from Selection”, or “Split Layer”, or “Track in mocha AE”. While not an officially endorsed method by Adobe, the executeMenuCommand() and findMenuCommandID() methods can come in handy sometimes. It certainly comes across as an easy solution, but I wouldn’t solely depend on this method if you plan on producing any public or professional scripts. Since it is not an officially supported feature of ExtendScript, it can and will break on you sometimes, so be forewarned. When assembled though, the two methods can make it as easy as typing in the menu name to launch said menu item. This is handy for some off beat menu items like the ones I mentioned above since they are not easily scriptable natively or at all in some cases.
In this episode we build a function that will allow you to simply call one line of code, runMenuCmd(“insert menu command here“). By simply placing the menu name or the command ID number in as an argument you can run this function numerous times easily within your script. Now if you are unfamiliar with command ID’s, then you should head over to an older post I did here on ProVideo Coalition about command ID’s and download the free PDF that I made of as many command ID’s that I could find here.
If you haven’t done so already there is a Free Function Friday introduction video located here that has some important information pointing to a few resources that will come in handy when scripting for After Effects.
Episode 2 runMenuCmd:
Legal note: The Adobe ExtendScript code talked about in this article and accompanying embedded video(s), and/or graphic images are not guaranteed to be compatible with every version of After Effects. David Torno, ProVideo Coalition, and Diversified will not be held liable for any misuse or incorrect use of the provided ExtendScript code. Use at your own risk.
All of the code I provide in this series, has been created and tested in After Effects CC 2014. Unless otherwise specified in the episode, the code should be compatible with After Effects CS6 through CC 2015. I’ve done my best to avoid depreciated code (code that Adobe removed at some point), and made these functions as compatible as possible. There will however be the occasional piece of code that is brand new as of a certain version of After Effects and therefore will not be backwards compatible from that version. I will mention these if that is the case.
With that said, all the code I provide in this series is open source and free to use in your scripts. I highly encourage you to expand and improve upon the code I provide and start making your own custom functions as well, but please do not repost the code I show in this series as is and claim it as your own. If you use any of the code provided in this series please give credit where credit is due. This series is meant to provide, what I feel is useful code, as well as to hopefully further explain ExtendScript and it’s quirks. While the functions we build throughout this series can perform a task all on their own, they are not meant to be a solo script. How you combine them together and expand upon them is when you will gain the most from these functions.