Coordinates of point in image given by user

Hello there!

I plan on creating a UXP Plugin with some perspective transformation operations.
Therefore I need coordinates of the points, which should be input by the user.

Ideal workflow would be:

  • User selects layer
  • User pushes button in plugin to start selecting cooridnates
  • User does 4 mouse clicks on image to select the coordiantes for the operation.

From what I’ve read there is no way to get current mouse position right now?
I’ve looked into letting the user do a polygonal selection beforehand but I couldn’t find a way to extract coordinates from there?
Is there any other way to do this besides letting the user input coordinates through a textfield?

Kind regards,
Tim

You can try converting your polygonal selection to a path with a high threshold and then get those points

Perhaps the Count Items or Color Sampler tool could be useful to you.

https://developer.adobe.com/photoshop/uxp/2022/ps_reference/classes/countitems/
https://developer.adobe.com/photoshop/uxp/2022/ps_reference/classes/colorsampler/

Thank you for your support!

I did a quick test setup with countItems and it seems to be very easy to implement.
I think this might be a fast and suitable way for the user to operate.