Another route could be this function that lets you specify inputWhite, inputBlack, gamma, outputWhite, outputBlack
setLevelAdj = function(inBlack, inWhite, gamma, outBlack, outWhite) {
var d, d1, d2, l, l1, l2, r, r1, s2t;
if (outBlack == null) {
outBlack = 0;
}
if (outWhite == null) {
outWhite = 255;
}
s2t = function(s) {
return app.stringIDToTypeID(s);
};
d = new ActionDescriptor();
r = new ActionReference();
r.putEnumerated(s2t('adjustmentLayer'), s2t('ordinal'), s2t('targetEnum'));
d.putReference(s2t('target'), r);
d1 = new ActionDescriptor();
d1.putEnumerated(s2t('presetKind'), s2t('presetKindType'), s2t('presetKindCustom'));
l = new ActionList();
d2 = new ActionDescriptor();
r1 = new ActionReference();
r1.putEnumerated(s2t('channel'), s2t('channel'), s2t('composite'));
d2.putReference(s2t('channel'), r1);
l1 = new ActionList();
l1.putInteger(inBlack);
l1.putInteger(inWhite);
d2.putList(s2t('input'), l1);
d2.putDouble(s2t('gamma'), gamma);
l2 = new ActionList();
l2.putInteger(outBlack);
l2.putInteger(outWhite);
d2.putList(s2t('output'), l2);
l.putObject(s2t('levelsAdjustment'), d2);
d1.putList(s2t('adjustment'), l);
d.putObject(s2t('to'), s2t('levels'), d1);
return executeAction(s2t('set'), d, DialogModes.NO);
};
Davide