I think I would try not to use any menu commands, if possible. So I’d try a workflow like this: you drop a marker layer at one end of the area you want to cut out and move the CTI (current time indicator) to the other end, and run a function like this (which you could attach to your button):
function splitAdjust(){
var myComp = app.project.activeItem;
if (!(myComp && (myComp instanceof CompItem))){
alert ("No comp selected.");
return;
}
if (! (myComp.selectedLayers.length > 0)){
alert("No layer selected.");
return;
}
var myLayer = myComp.selectedLayers[0];
if (! (myLayer.property("Marker").numKeys > 0)){
alert("Selected layer has no marker.");
return;
}
var compTime = myComp.time;
var markerTime = myLayer.property("Marker").keyTime(1);
myDup = myLayer.duplicate();
myDup.moveAfter(myLayer);
if (markerTime < compTime){
var t1 = markerTime;
var t2 = compTime;
}else{
var t1 = compTime;
var t2 = markerTime;
}
myLayer.outPoint = t1;
myDup.inPoint = t2;
myDup.startTime -= t2-t1;
myLayer.property("Marker").removeKey(1);
myDup.property("Marker").removeKey(1);
}
splitAdjust();