To paste code click the >> and select Syntack Highlighting, then make your selection. I normally choose Plain. I have tidied your function and it now works for me on CS6.
#target photoshop;
app.bringToFront();
if(documents.length){
var Colour = new SolidColor();
Colour.rgb.hexValue='ff0000'; //red fill
Rectangle(100,10,300,300,300,Colour);
}
function Rectangle(recLeft,recTop,recRight,recBottom,recResolution,Colour) {
var desc2 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass( stringIDToTypeID('contentLayer') );
desc2.putReference( charIDToTypeID('null'), ref1 );
var desc3 = new ActionDescriptor();
var desc4 = new ActionDescriptor();
var desc5 = new ActionDescriptor();
desc5.putDouble( charIDToTypeID('Rd '), Colour.rgb.red );
desc5.putDouble( charIDToTypeID('Grn '), Colour.rgb.green );
desc5.putDouble( charIDToTypeID('Bl '), Colour.rgb.blue );
desc4.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), desc5 );
desc3.putObject( charIDToTypeID('Type'), stringIDToTypeID('solidColorLayer'), desc4 );
var desc6 = new ActionDescriptor();
desc6.putInteger( stringIDToTypeID('unitValueQuadVersion'), 1 );
desc6.putUnitDouble( charIDToTypeID('Top '), charIDToTypeID('#Pxl'), recTop );
desc6.putUnitDouble( charIDToTypeID('Left'), charIDToTypeID('#Pxl'), recLeft );
desc6.putUnitDouble( charIDToTypeID('Btom'), charIDToTypeID('#Pxl'), recBottom );
desc6.putUnitDouble( charIDToTypeID('Rght'), charIDToTypeID('#Pxl'), recRight );
desc6.putUnitDouble( stringIDToTypeID('topRight'), charIDToTypeID('#Pxl'), -1.000000 );
desc6.putUnitDouble( stringIDToTypeID('topLeft'), charIDToTypeID('#Pxl'), -1.000000 );
desc6.putUnitDouble( stringIDToTypeID('bottomLeft'), charIDToTypeID('#Pxl'), -1.000000 );
desc6.putUnitDouble( stringIDToTypeID('bottomRight'), charIDToTypeID('#Pxl'), -1.000000 );
desc3.putObject( charIDToTypeID('Shp '), charIDToTypeID('Rctn'), desc6 );
var desc7 = new ActionDescriptor();
desc7.putInteger( stringIDToTypeID('strokeStyleVersion'), 2 );
desc7.putBoolean( stringIDToTypeID('strokeEnabled'), false );
desc7.putBoolean( stringIDToTypeID('fillEnabled'), true );
desc7.putUnitDouble( stringIDToTypeID('strokeStyleLineWidth'), charIDToTypeID('#Pnt'), 3.000000 );
desc7.putUnitDouble( stringIDToTypeID('strokeStyleLineDashOffset'), charIDToTypeID('#Pnt'), 0.000000 );
desc7.putDouble( stringIDToTypeID('strokeStyleMiterLimit'), 100.000000 );
desc7.putEnumerated( stringIDToTypeID('strokeStyleLineCapType'), stringIDToTypeID('strokeStyleLineCapType'), stringIDToTypeID('strokeStyleButtCap') );
desc7.putEnumerated( stringIDToTypeID('strokeStyleLineJoinType'), stringIDToTypeID('strokeStyleLineJoinType'), stringIDToTypeID('strokeStyleMiterJoin') );
desc7.putEnumerated( stringIDToTypeID('strokeStyleLineAlignment'), stringIDToTypeID('strokeStyleLineAlignment'), stringIDToTypeID('strokeStyleAlignInside') );
desc7.putBoolean( stringIDToTypeID('strokeStyleScaleLock'), false );
desc7.putBoolean( stringIDToTypeID('strokeStyleStrokeAdjust'), false );
var list1 = new ActionList();
desc7.putList( stringIDToTypeID('strokeStyleLineDashSet'), list1 );
desc7.putEnumerated( stringIDToTypeID('strokeStyleBlendMode'), charIDToTypeID('BlnM'), charIDToTypeID('Nrml') );
desc7.putUnitDouble( stringIDToTypeID('strokeStyleOpacity'), charIDToTypeID('#Prc'), 100.000000 );
var desc8 = new ActionDescriptor();
var desc9 = new ActionDescriptor();
desc9.putDouble( charIDToTypeID('Rd '), 0.000000 );
desc9.putDouble( charIDToTypeID('Grn '), 0.000000 );
desc9.putDouble( charIDToTypeID('Bl '), 0.000000 );
desc8.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), desc9 );
desc7.putObject( stringIDToTypeID('strokeStyleContent'), stringIDToTypeID('solidColorLayer'), desc8 );
desc7.putDouble( stringIDToTypeID('strokeStyleResolution'), recResolution );
desc3.putObject( stringIDToTypeID('strokeStyle'), stringIDToTypeID('strokeStyle'), desc7 );
desc2.putObject( charIDToTypeID('Usng'), stringIDToTypeID('contentLayer'), desc3 );
executeAction( charIDToTypeID('Mk '), desc2, DialogModes.NO );
};
... View more