// Save the current preferences var startRulerUnits = app.preferences.rulerUnits; // Set Photoshop to use pixels app.preferences.rulerUnits = Units.PIXELS; Main(); // Return the app preferences app.preferences.rulerUnits = startRulerUnits; function Main() { if (app.activeDocument.colorSamplers.length!=2) { alert('two color sampler points are required'); return; } else { point1 = []; point2 = []; var mySampler = app.activeDocument.colorSamplers[0]; //find out where x y coordinates of first sampler are var samptx =mySampler.position[0]; var sampty =mySampler.position[1]; var sampx = parseInt(samptx); var sampy = parseInt(sampty); for (var s=0,len=app.activeDocument.colorSamplers.length;s