// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits;
// Set Adobe Photoshop CS2 to use pixels
app.preferences.rulerUnits = Units.PIXELS
// Set the appropriate values
var HD = 100; // horizontal diameter
var VD = 50; // vertical diameter
var X = 100; // horizontal center of selection
var Y = 100; // vertical center of selection
// The script's body
var desc8 = new ActionDescriptor();
var desc9 = new ActionDescriptor();
var ref3 = new ActionReference();
var unitsID = charIDToTypeID( "#Pxl" );
desc9.putUnitDouble( charIDToTypeID( "Top " ), unitsID, Y - (VD/2) );
desc9.putUnitDouble( charIDToTypeID( "Left" ), unitsID, X - (HD/2) );
desc9.putUnitDouble( charIDToTypeID( "Btom" ), unitsID, Y + (VD/2) );
desc9.putUnitDouble( charIDToTypeID( "Rght" ), unitsID, X + (HD/2) );
ref3.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
desc8.putReference( charIDToTypeID( "null" ), ref3 );
desc8.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Elps" ), desc9 );
desc8.putBoolean( charIDToTypeID( "AntA" ), true );
executeAction( charIDToTypeID( "setd" ), desc8, DialogModes.NO );
// Reset the application preferences
app.preferences.rulerUnits = startRulerUnits;