Is there a way to get the cursor coordinates?
I would like to sample pixels values at different places on the document.
The colorSamplers needs those to work.
This would be of great help and appreciated
That’s been a long time feature request of mine, but it seemed like the cursor position (found in the Info palette) is not surfaced to the scripting layer.
1 Like
@DavideBarranca I hope it helps but you already know that
OK! I found a solution using the colorSamplers and the listener for “Make colorSampler”.
You can extract color & coordinates from the colorSampler.
So, here it is:
const cs = app.activeDocument.colorSamplers[0]; // 0 for first colorSamplers, 1 for second colorSamplers
const { color, position } = cs; // destructuring assignment
// Coordinates used to write the color at the spot
positionX = Number(position.x)/w*100;
positionY = Number(position.y)/h*100;
// Color info to be written on the document
myRed = Math.round(color.rgb.red)
myGreen = Math.round(color.rgb.green)
myBlue = Math.round(color.rgb.blue)