It could, but that would require a UI for the script, which is a bit of work. Here’s how the basic functionality might look though:
function setKF(){
var myComp = app.project.activeItem;
if (! (myComp && (myComp instanceof CompItem))){
alert("No comp active.");
return;
}
var myProps = myComp.selectedProperties;
if (myProps.length == 0){
alert("No property selected.");
return;
}
var myProp = null;
for (var i = 0; i < myProps.length; i++){
if (myProps[i].numKeys >= 2){
myProp = myProps[i];
break;
}
}
if (myProp == null){
alert ("No property with 2 or more keyframes selected.");
return;
}
var tStart = myComp.workAreaStart;
var tEnd = tStart + myComp.workAreaDuration;
var myExpr = "t = linear(time," + tStart + "," + tEnd + ",key(1).time,key(numKeys).time);\rvalueAtTime(t)";
myProp.expression = myExpr;
}
setKF();