Copy link to clipboard
Copied
I wish to have a button in my photoshop actions which when pressed open up a window with buttons to choce further actions from. I use a lot of actions and this would help me find the right set more easly
try this:
var s2t = stringIDToTypeID,
atn = getActionsList(),
cur = getActionName();
if (cur && atn[cur]) {
var cursor = (getXY()),
w = new Window("dialog", cur);
w.preferredSize = [200, 200];
w.spacing = 0;
w.location = [cursor[0], cursor[1] + 100]
for (var i = 0; i < atn[cur].length; i++) {
var b = w.add('button')
b.text = atn[cur][i];
b.onClick = function () {
w.close()
doAction(this.text, cur)
}
...
Copy link to clipboard
Copied
Do you have any Photoshop Scripting or general JavaScript experience?
Copy link to clipboard
Copied
I know enough to edit java but not to created it from scratch
Copy link to clipboard
Copied
The following extension can find actions by a search filter:
https://exchange.adobe.com/creativecloud.details.101656.action-launcher-free.html
Copy link to clipboard
Copied
Are you aware of button mode in Photoshop? Buttons can be colorized for easier navigation or find.
Copy link to clipboard
Copied
Perhaps you will be satisfied with this option: When launched, the script gets the name of the action from which it was launched, then searches for a set with the same name among the loaded ones and displays a window with buttons, each of which launches the action of the specified set. Not perfect, but it works.
var s2t = stringIDToTypeID,
atn = getActionsList(),
cur = null;
try {
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('name'));
r.putEnumerated(s2t('action'), s2t('ordinal'), s2t('targetEnum'));
cur = executeActionGet(r).getString(p);
} catch (e) { }
if (cur && atn[cur]) {
var cursor = (getXY()),
w = new Window("dialog", cur);
w.preferredSize = [200, 200];
w.spacing = 0;
w.location = [cursor[0], cursor[1]+100]
for (var i = 0; i < atn[cur].length; i++) {
var b = w.add('button')
b.text = atn[cur][i];
b.onClick = function () {
w.close()
doAction(this.text, cur)
}
}
w.show();
function getXY() {
var w = new Window("dialog {alignChildren: ['fill','fill'], margins: 0}"),
g = w.add("button"),
X, Y;
w.preferredSize = [$.screens[0].right, $.screens[0].bottom]
g.addEventListener('mouseover', handler)
function handler(evt) { w.close(); X = evt.screenX, Y = evt.screenY }
w.show();
return [X, Y]
}
}
function getActionsList() {
var output = {},
setCounter = 1
while (true) {
(r = new ActionReference()).putIndex(s2t('actionSet'), setCounter);
try { desc = executeActionGet(r) } catch (e) { break; }
var numberChildren = desc.hasKey(s2t('numberOfChildren')) ? desc.getInteger(s2t('numberOfChildren')) : 0
if (numberChildren > 0) {
output[desc.getString(s2t('name'))] = getActionList(setCounter, numberChildren)
}
setCounter++
}
return output;
function getActionList(setIndex, numChildren) {
var current = []
for (var i = 1; i <= numChildren; i++) {
(r = new ActionReference()).putIndex(s2t('action'), i);
r.putIndex(s2t('actionSet'), setIndex)
current.push(executeActionGet(r).getString(s2t('name')))
}
return current
}
}
Copy link to clipboard
Copied
This looks really useful, thank you. I will try it out tomorrow.
Copy link to clipboard
Copied
Hi jazz-y
I Finally got around to trying out this Script. It works as it should when i create it but then not when i play the action after. The pathway is there to the action's laoction and I have checked the script again. any ideas? I am really keen to get this working.
Thank you again.
Copy link to clipboard
Copied
try this:
var s2t = stringIDToTypeID,
atn = getActionsList(),
cur = getActionName();
if (cur && atn[cur]) {
var cursor = (getXY()),
w = new Window("dialog", cur);
w.preferredSize = [200, 200];
w.spacing = 0;
w.location = [cursor[0], cursor[1] + 100]
for (var i = 0; i < atn[cur].length; i++) {
var b = w.add('button')
b.text = atn[cur][i];
b.onClick = function () {
w.close()
doAction(this.text, cur)
}
}
w.show();
function getXY() {
var w = new Window("dialog {alignChildren: ['fill','fill'], margins: 0}"),
g = w.add("button"),
X, Y;
w.preferredSize = [$.screens[0].right, $.screens[0].bottom]
g.addEventListener('mouseover', handler)
function handler(evt) { w.close(); X = evt.screenX, Y = evt.screenY }
w.show();
return [X, Y]
}
}
function getActionsList() {
var output = {},
setCounter = 1
while (true) {
(r = new ActionReference()).putIndex(s2t('actionSet'), setCounter);
try { desc = executeActionGet(r) } catch (e) { break; }
var numberChildren = desc.hasKey(s2t('numberOfChildren')) ? desc.getInteger(s2t('numberOfChildren')) : 0
if (numberChildren > 0) {
output[desc.getString(s2t('name'))] = getActionList(setCounter, numberChildren)
}
setCounter++
}
return output;
function getActionList(setIndex, numChildren) {
var current = []
for (var i = 1; i <= numChildren; i++) {
(r = new ActionReference()).putIndex(s2t('action'), i);
r.putIndex(s2t('actionSet'), setIndex)
current.push(executeActionGet(r).getString(s2t('name')))
}
return current
}
}
function getActionName() {
var atn;
try {
(r = new ActionReference()).putEnumerated(s2t('action'), s2t('ordinal'), s2t('targetEnum'));
var parent = executeActionGet(r).getString(s2t('parentName')),
title = executeActionGet(r).getString(s2t('name'));
try {
(r = new ActionReference()).putName(s2t('actionSet'), title);
executeActionGet(r).getInteger(s2t('itemIndex'));
atn = title;
} catch (e) {
(r = new ActionReference()).putName(s2t('actionSet'), parent);
executeActionGet(r).getInteger(s2t('itemIndex'));
atn = parent;
}
}
catch (e) { atn = null }
return atn;
}
Copy link to clipboard
Copied
Thank you, that works everytime, you have been a great help.
Copy link to clipboard
Copied
Hi sorry there is one last glich, when i run the action and the submenu of action come up, what ever one i press it plays the bottom one in that set. Thank you again for your help.
Copy link to clipboard
Copied
change line
doAction(b.text, cur)
to:
doAction(this.text, cur)
This should fix the issue.
Copy link to clipboard
Copied
Just made the change, all works as it should. Thank you for your help
Copy link to clipboard
Copied
I also forgot about Paul Riggott's Action Finder script:
https://github.com/Paul-Riggott/PS-Scripts/blob/master/Action%20Finder.jsx
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Copy link to clipboard
Copied
Thank you this looks great, I have over 150 diffrent actions and this will save alot of time.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now