Copy link to clipboard
Copied
Hi, I'm not sure this belongs in the scripting section so maybe I can ask in both this section and the main section.
I'm looking to find a way to move a particular layer to the cursor. SO in other words, imagine you're working on a document with several layers, and you're really zoomed in. I want to be able to select the layer I wish to move by clicking on it in the layers panel, then perhaps run the script (or other method), which will then move that layer in question to wherever the cursor is at that moment. This eliminates the need to zoom way out, click on the layer in the panel, then move it to where I was working, then zoom way back in again. Just imagine that the layer I wish to move contains just a little color dab/pallet thing that I made to sample colors from. I don't want to have to keep zooming out, pull that layer over to where I was zoomed in and then zoom back in again to keep working. I hope this makes sense.
Is there a stock way to do this in photoshop or is it a more complicated (or impossible) thing to do?
Thanks!
Copy link to clipboard
Copied
I know of no way to find out the mouse cursor location in a Photoshop Script. You can use to color sampler tool to mark up tp 10 location in a Photoshop document. But I do not think it posible to get the mouse coursor position in a Photoshop script.
You can also set a selection and align layers to the selection. Set guides and align layers to guides
http://www.mouseprints.net/old/dpr/FitImageToGuides.jsx
http://www.mouseprints.net/old/dpr/RotateLayerAbout.jsx
Copy link to clipboard
Copied
thanks, JJ. If I could mark the cursor's location with the color sampler tool, would I then be able to move the layer in question to its x,y location?
Copy link to clipboard
Copied
The ColorSamplers’ position can even be evaluated with DOM code, calculating the necessary offset to translate the Layer should not be a problem.
// 2015, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theArray = new Array;
for (var m = 0; m < myDocument.colorSamplers.length; m++) {
theArray.push(myDocument.colorSamplers
.position) };
alert (theArray.join("\n"));
};
Copy link to clipboard
Copied
Hi,
in case you need more than 10 x/y locations, you can do the same with the Count tool.
Davide
Copy link to clipboard
Copied
thanks guys, yes c.pfaffenbichler, the script returns the x y coordinates of the color sampler point successully. very useful. I also managed to work out another way to do it. It's useful for painters if they want to pull over their little swatch pallet to the exact location they're painting at when zoomed in really close. (not the Swatches Panel, but a manual swatch pallet that they might have sketched out themselves)
1. Ensure the layer you wish to move is the active layer
2. Create any sort of a selection using the lasso tool at the exact area you're working in. Can be any size, anywhere on your document as long as it's close to where you're working.
3. Select the Move Tool.
4. In the options bar, there are now little icons. Click on the "Align Horizontal Centers" icon, and then click on the "Align Vertical Centers" icon. The layer now moves to the selection.
A bit of a task to be honest, but it's a little easier than zooming way out, dragging the layer in question to where you were just working, and then zooming way back in again.
Copy link to clipboard
Copied
1. Ensure the layer you wish to move is the active layer
2. Create any sort of a selection using the lasso tool at the exact area you're working in. Can be any size, anywhere on your document as long as it's close to where you're working.
4. In the options bar, there are now little icons. Click on the "Align Horizontal Centers" icon, and then click on the "Align Vertical Centers" icon. The layer now moves to the selection.
A bit of a task to be honest, but it's a little easier than zooming way out, dragging the layer in question to where you were just working, and then zooming way back in again.
Its 1 target layers to be aligned, 2 make a selection to align the layers to and 4 the two align steps. 3 the move tool is not required. And 4 is a simple key press. You just need to record the two align steps into an action and assign a shortcut like F2 to the action.
Step 1 menu Layer>Align Layers to Selection>Vertical Center
Step 2 menu Layer>Align Layers to Selection>Horizontal Center
Copy link to clipboard
Copied
Awesome!! Thanks JJ! I thought we had to select the move tool for it to work. Now that it's unnecssary, everything is running even better. It's an extra step we didn't need
Find more inspiration, events, and resources on the new Adobe Community
Explore Now