This content has been marked as final.
Show 3 replies
-
1. Re: Color Select Script Needs Refining
Paul Riggott Nov 11, 2011 3:22 PM (in response to carleq)This should do an average...
#target Photoshop function main(){ if(!documents.length) return; var startRulerUnits = app.preferences.rulerUnits; app.preferences.rulerUnits = Units.PIXELS; try{ app.activeDocument.colorSamplers.removeAll(); var X = activeDocument.width/2; var LB=[]; LB[0] = X.value; LB[1] = 1; LB[2] = X.value +5; LB[3] = 6; var tmpColour = new SolidColor(); var savedState = activeDocument.activeHistoryState; activeDocument.selection.select([[LB[0],LB[1]], [LB[2],LB[1]], [LB[2],LB[3]], [LB[0], LB[3]]], SelectionType.REPLACE, 0, false); activeDocument.activeLayer.applyAverage(); var sample = activeDocument.colorSamplers.add( [ new UnitValue( X+1, 'px' ), new UnitValue( 2, 'px' ) ] ); tmpColour=sample.color; activeDocument.activeHistoryState = savedState; app.backgroundColor=tmpColour; app.preferences.rulerUnits = startRulerUnits; }catch(e){alert(e + " - " + e.line);} } main();I haven't been able to stop the info panel appearing so I add it to my open panels so it's not intrusive.
-
2. Re: Color Select Script Needs Refining
carleq Nov 12, 2011 6:50 AM (in response to Paul Riggott)It's superb, Paul, superb.
The only problem was that running the script opened Units & Rulers preferences twice and I needed to dialog "OK."
Because the script was just setting rulers to pixels, which I almost always use anyway, I just removed these lines from the script:
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.rulerUnits = startRulerUnits;
...and everything works great! Thanks, Paul.
-
3. Re: Color Select Script Needs Refining
carleq Nov 12, 2011 6:52 AM (in response to Paul Riggott)And I almost forgot to say thanks, Paul for the INFO panel idea. Just keep it open, out of the way. That works.

