Skip to content

Instantly share code, notes, and snippets.

View zlovatt's full-sized avatar

Zack Lovatt zlovatt

View GitHub Profile
@zlovatt
zlovatt / CEP Debugging in vscode.md
Last active February 23, 2023 07:54
CEP Debugging in vscode

Setup

  • in .vscode folder in your project root, create a file launch.json
{
  "version": "0.1.0",
  "configurations": [
    {
      "name": "[Your Tool] Debugger",
 "type": "chrome",
@zlovatt
zlovatt / aeq-listbox.js
Created October 13, 2020 19:06
Example script for creating a listbox via aequery
(function () {
// Set path below to your aeq.js path
//@include "path/to/aequery.js"
function createPanel() {
var win = aeq.ui.createWindow("Listbox Test");
var pnl = win.addPanel("List");
pnl.set({
orientation: "row",
@zlovatt
zlovatt / getEnums.jsx
Last active January 8, 2023 00:04
Extendscript: AE enum values (17.7)
(function () {
var allEnums = {
AlphaMode: {},
AutoOrientType: {},
BlendingMode: {},
ChannelType: {},
CloseOptions: {},
FastPreviewType: {},
FeetFramesFilmType: {},
FieldSeparationType: {},
@zlovatt
zlovatt / aeCameraData.jsx
Last active January 19, 2022 05:59
Extendscript: Get After Effects Camera Data
// Figuring out some math to determine aov, filmSize and focalLength in an AE camera, as these values aren't script-accessible.
// Assuming units are pixels, film size measuring horizontally
var comp = app.project.activeItem;
var camera = your camera layer;
var compSize = comp.width;
var cameraZoom = camera.zoom;
var depthOfField = camera.depthOfField;
var focusDistance = camera.focusDistance;
@zlovatt
zlovatt / getFocusedComp.jsx
Last active September 20, 2022 03:55
Extendscript: Gets currently open comp from timeline, as opposed to selected comp in project panel
(function () {
/**
* Gets currently open comp from timeline, as opposed to
* selected comp in project panel
*
* @returns {CompItem | null} Active comp, or null if none
*/
function getFocusedComp() {
var activeItem = app.project.activeItem;
@zlovatt
zlovatt / getClipboardContents.jsx
Last active July 6, 2021 16:53
Extendscript: Get Clipboard Contents (Windows only)
// This will get the clipboard contents directly as a string
var clipboardContents = system.callSystem("cmd /c \"for /f \"eol=; tokens=* delims= \" %I in ('powershell Get-Clipboard') do @set CLIPBOARD_TEXT=%I && echo %I\"");
@zlovatt
zlovatt / getSetTemplatePath.jsx
Last active July 6, 2021 16:52
Extendscript: Get & Set After Effects Template Path
function getTemplatePath () {
if (parseFloat(app.version) < 14.0) return;
try {
if (app.preferences.havePref("Template Project", "Location", PREFType.PREF_Type_MACHINE_INDEPENDENT)) {
return app.preferences.getPrefAsString("Template Project", "Location", PREFType.PREF_Type_MACHINE_INDEPENDENT);
} else {
throw new Error("Template Project Location preference does not exist.");
}
} catch(e) {
@zlovatt
zlovatt / getAudioItemkbps.jsx
Created July 6, 2021 16:52
Extendscript: get audio file bitrate
// This doesn't check that the selection is valid, or that it's an audio file.
// Based on: http://stackoverflow.com/questions/21634091/is-it-possible-to-get-bitrate-of-mp3
(function () {
var item = app.project.selection[0];
var duration = item.duration;
var fileSize = item.file.length;
var kbit = fileSize/128;
var kbps = Math.ceil(Math.round(kbit / duration) / 16) * 16;
@zlovatt
zlovatt / copyToWinClipboard.jsx
Created July 6, 2021 16:53
Extendscript: Copy string to Windows clipboard
// Copy string from ESTK to Windows clipboard:
var myString = "Here is a string";
var cmdString = 'cmd.exe /c cmd.exe /c "echo ' + myString + ' | clip"';
system.callSystem(cmdString);
@zlovatt
zlovatt / getLayerType.jsx
Last active May 29, 2024 04:48
ExtendScript: Get AE Layer Type
(function getSelectedLayerType() {
/**
* Gets the type of a given layer
*
* @param {Layer} layer Layer to check
* @return {string} Layer type
*/
function getLayerType(layer) {
switch (layer.matchName) {
case "ADBE Vector Layer":