# Cursor position

**URL:** <https://forums.creativeclouddeveloper.com/t/cursor-position/6195>\
**Category:** Photoshop\
**Created:** [April 19, 2023, 3:43pm UTC](https://forums.creativeclouddeveloper.com/t/cursor-position/6195 "2023-04-19T15:43:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdophoto](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pdophoto/32/1304_2.png) [@pdophoto](https://forums.creativeclouddeveloper.com/u/pdophoto)\
**Post date:** [April 19, 2023, 3:43pm UTC](https://forums.creativeclouddeveloper.com/t/cursor-position/6195/1 "2023-04-19T15:43:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DavideBarranca](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/davidebarranca/32/1523_2.png) [@DavideBarranca](https://forums.creativeclouddeveloper.com/u/DavideBarranca)\
**Post date:** [April 20, 2023, 9:16am UTC](https://forums.creativeclouddeveloper.com/t/cursor-position/6195/2 "2023-04-20T09:16:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pdophoto](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pdophoto/32/1304_2.png) [@pdophoto](https://forums.creativeclouddeveloper.com/u/pdophoto)\
**Post date:** [April 24, 2023, 7:27pm UTC](https://forums.creativeclouddeveloper.com/t/cursor-position/6195/3 "2023-04-24T19:27:41Z")

</div>

@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:

```auto
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)

```
