Copy link to clipboard
Copied
What I want to do in Photoshop (version CC, but I think this applies to any version) is label a point using count tool under my mouse's current position, and label it multiple times (for different labels). I have an action that essentially does this:
(1) Add to count (under one label) (2) Switch to second label (3) Add to count (under second label) (4) Switch to third label (5) Add to count (under third label)
And the problem is that I need to be able to have a variable in the action script that uses the cursor's current position (X and Y numbers) on the canvas to set these three points when the macro is activated. Currently I am only able to record the script using constant X, Y values (the same point is labeled over and over when I play the recorded action). I am able to extract the code for the action for editing (via xbytor2's suggestion in this forum:https://forums.adobe.com/thread/696989) and I see where the variable can go, I just don't know what exactly to put in place of the constant X, Y values that will let Photoshop input the mouse's current coordinates...
Any ideas? Much appreciated!!
Copy link to clipboard
Copied
You could use the pen tool set to path and create a single dot, then run the script to get the cursor positions and use that in your script.
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
var doc = activeDocument;
var workPath = doc.pathItems.getByName("Work Path");
var pos = workPath.subPathItems[0].pathPoints[0].leftDirection;
$.writeln("x = " + pos[0] + " y = " + pos[1]);
doc.pathItems.getByName("Work Path").remove();
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
Copy link to clipboard
Copied
Thank you for this neat suggestion, I will try it soon and get back to you.
Copy link to clipboard
Copied
Hi,
I'm afraid it's not completely clear to me what you're after, yet if I understand you're asking whether it is possible to retrieve via scripting the live X/Y coordinates of the mouse pointer (as the Info palette shows when you move it) - am I right?
To the best of my knowledge, the answer is no - I requested this feature a while ago, but it's never been implemented. I'd be glad to be proved wrong!
Hope this helps,
Davide Barranca
---
www.davidebarranca.com
www.cs-extensions.com
Copy link to clipboard
Copied
Yes, the info palette X/Y values are what I am after. The program already seems to be storing that information somewhere (in a variable?) in order to display it, and so ideally, and most simply, I can just input those X/Y variable names into my action script to mark live points...
Do you know if there is a way to view the coding for the info palette? I'm not sure if that's allowed...
Copy link to clipboard
Copied
Your point is exactly the same I made - the info is available live to PS, yet it's not exposed via the DOM (nor via ActionManager).
Davide
Copy link to clipboard
Copied
Has this been added to CEP7.0 and in CC2016 to 2017?
Copy link to clipboard
Copied
Not that I'm aware of it, Satish.
Copy link to clipboard
Copied
No about all you can to at this time is to use the color sample tool to set up to 10 points then run a script to process the points x,y positions you set.
A question I have for you if a script could get the mouse current location how would the script know when to get mouse position or what to do if its not over the Active document canvas or the active document is zoomed to other than 100%.
With the color sampler tool points you know the point are within the image but if the image is scaled to other than 100% Zoom. Is the point the one you want or just close to the point.
I would think if a script could get the position I guess it could look some type of mouse gesture then get the point when the mouse stop all movement. Often I use a Wacom pen I do not know if I could hold the pen that still.
var orig_ruler_units = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS
message="Canvas Width=" + app.activeDocument.width.value + " ,Height=" + app.activeDocument.height.value;
for (var s=0,len=app.activeDocument.colorSamplers.length;s<len;s++) {
var colorSamplerRef = app.activeDocument.colorSamplers;
message = message + "\nColorSampler=" + s + " ,x=" + colorSamplerRef.position[0].value + " ,y=" + colorSamplerRef.position[1].value;
}
alert(message);
app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings