After a day of searching the web, trying out things and writing my first AE script for my hugely repetitive task, I found a way to assign hotkeys to scripts, using Applescript and Quicksilver. Through Applescript, you can run your AE (jsx) script from outside of AE, as documented in the scripting manual.
In my case, calling the script file didn't work, but pasting the entire script code in my Applescript did (be sure to escape your double quotes!).
So, if I ran the Applescript, it actually executed the things I wanted inside AE.
Now, with Quicksilver, you can add custom triggers, basically hotkeys to files, apps or other actions. If you create a custom trigger with your applescript as destination, it will run this. In my case, hitting Ctrl-§ would trigger my script (choose an unused key combination, ofcourse).
This all works perfectly, and it might save you some time and strain from all that repetitive mousing action

Quicksilver can be found here
My jsx script (which toggles the opacity between 0 and 100, creating a keyframe 1 frame before the current time holding the current opacity, and creating a keyframe at the current time with the new opacity):
Code: Select all
{
// OpacityToggle.jsx
//
// Author: Emar Vegt, 2008
function OpacityToggle(myComp){
var comp_layers = myComp.layers;
var length = myComp.selectedLayers.length;
var SNA = new Array();
var curOp;
var curOp;
var newOp;
var curTime = myComp.time;
var prevFrameTime = curTime - ( 1 / myComp.frameRate ); // time of previous frame
if (length > 0) // only process 2 or more selected layers
{
for(j = 0; j < length; j++) // collect in array SNA all layers which should we reordered
{
SNA[j]=myComp.selectedLayers[j].index;
//**
cAi=SNA[j]; // Index of current layer A, top
var lTMA = comp_layers[cAi]; // assign lTMA to current layer A
Op = lTMA.property("Transform").property("Opacity");
curOp = Op.valueAtTime(curTime,false );
if (curOp == 100) { newOp = 0; }
else { newOp = 100; }
Op.setValueAtTime(prevFrameTime, curOp);
Op.setValueAtTime(curTime, newOp);
//**
} // end for-loop
}
}
var proj = app.project;
var undoStr = "OpacityToggle";
if (proj){
var activeItem = app.project.activeItem;
if (activeItem != null && (activeItem instanceof CompItem)){
app.beginUndoGroup(undoStr);
OpacityToggle(activeItem);
app.endUndoGroup();
} else {
alert("Please select an active comp to use this script");
}
}
else
{
alert("Please open a project first to use this script.");
}
}
Code: Select all
tell application "Adobe After Effects CS3"
DoScript "
function OpacityToggle(myComp){
var comp_layers = myComp.layers;
var length = myComp.selectedLayers.length;
var SNA = new Array();
var curOp;
var curOp;
var newOp;
var curTime = myComp.time;
var prevFrameTime = curTime - ( 1 / myComp.frameRate ); // time of previous frame
if (length > 0) // only process 2 or more selected layers
{
for(j = 0; j < length; j++) // collect in array SNA all layers which should we reordered
{
SNA[j]=myComp.selectedLayers[j].index;
//**
cAi=SNA[j]; // Index of current layer A, top
var lTMA = comp_layers[cAi]; // assign lTMA to current layer A
Op = lTMA.property(\"Transform\").property(\"Opacity\");
curOp = Op.valueAtTime(curTime,false );
if (curOp == 100) { newOp = 0; }
else { newOp = 100; }
Op.setValueAtTime(prevFrameTime, curOp);
Op.setValueAtTime(curTime, newOp);
//**
} // end for-loop
}
}
var proj = app.project;
var undoStr = \"OpacityToggle\";
if (proj){
var activeItem = app.project.activeItem;
if (activeItem != null && (activeItem instanceof CompItem)){
app.beginUndoGroup(undoStr);
OpacityToggle(activeItem);
app.endUndoGroup();
} else {
alert(\"Please select an active comp to use this script\");
}
}
else
{
alert(\"Please open a project first to use this script.\");
}
"
end tell
