Execute a script via a button
Copy link to clipboard
Copied
hi every one
I write a code to Execute a script via a button but i it didi not work can you help me to fiv this problem
thanks
the code:
function playAction(se1 ,action1){
setFound=false;
actionFound=false;
const actionSets = require('photoshop').app.actionTree;
// check for action set name to exist
if (actionSets[i].name==se1){var setToPlay=actionSets[i]; setFound=true;}
//check for action name to exist
if (setToPlay.actions[i].name==action1){var actionToPlay=setToPlay.actions[i]; actionFound=true;}
//play if action set/action both exist
if(setFound==true&&actionFound==true){await actionToPlay.play();}
}
Explore related tutorials & articles
Copy link to clipboard
Copied
any help pleas
Copy link to clipboard
Copied
hi
i want acode to run my script via abutton from the ui window
i tray so many wayes but i cant do it if any one can help me please?
thanks for all
[Moderator moved the thread to the correct forum]
[Triplicate posts merged by moderator]
Copy link to clipboard
Copied
This is not a coding forum. Please tell us, what Adobe application you use and we will move the thread to the correct forum.
Copy link to clipboard
Copied
hi photoshop
Copy link to clipboard
Copied
You should still give the full version number of your Photoshop programm and a better description of what you want to achieve. The more information you post here, the more accurate answers will be.
Copy link to clipboard
Copied
thank you so much i post in correct forum.
thank you so much sir
Copy link to clipboard
Copied
Run the script from an Action.
Copy link to clipboard
Copied
hi
i want acode to run my script via abutton from the ui window
i tray so many wayes but i cant do it if any one can help me please?
this is my code
function SimpleDialog() {
var w = new Window('dialog', '');
this.windowRef = w;
w.orientation = "column";
btn1 = w.add('button',undefined,'Button 1');
btn1.onClick = function() {("Button 1");
var scriptFile = File("c/Adobe/select only the spot channels.jsx");
var script;
scriptFile.open('select only the spot channels.jsx');
script = scriptFile.read();
scriptFile.close();
eval(script);
};
btnOK.onClick = function() {
w.close();
}
w.show();
}
SimpleDialog ();
if (stuff) alert(stuff);
thanks for all
Copy link to clipboard
Copied
var desc4 = new ActionDescriptor();
desc4.putPath( charIDToTypeID( "jsCt" ), new File(/*insert the correct path here*/) );
desc4.putString( charIDToTypeID( "jsMs" ), "undefined" );
executeAction( stringIDToTypeID( "AdobeScriptAutomation Scripts" ), desc4, DialogModes.NO );
Copy link to clipboard
Copied
thank you so much but i use this code but it do nothing
function SimpleDialog() {
var w = new Window('dialog', '');
this.windowRef = w;
w.orientation = "column";
btn1 = w.add('button',undefined,'Button 1');
btn1.onClick = function() {("Button 1");
var desc4 = new ActionDescriptor();
desc4.putPath( charIDToTypeID( "jsCt" ), new File(/*c/Adobe/select only the spot channels.jsx*/) );
desc4.putString( charIDToTypeID( "jsMs" ), "undefined" );
executeAction( stringIDToTypeID( "AdobeScriptAutomation Scripts" ), desc4, DialogModes.NO );
};
btn1.onClick = function() {
w.close();
}
w.show();
}
Copy link to clipboard
Copied
Try this on a file with artboards.
function SimpleDialog() {
var w = new Window('dialog', '');
this.windowRef = w;
btn1 = w.add('button',undefined,'Button 1');
btn1.onClick = function() {
var desc4 = new ActionDescriptor();
desc4.putPath( charIDToTypeID( "jsCt" ), new File("/Applications/Adobe Photoshop 2024/Presets/Scripts/ArtBoards To Files.jsx") );
desc4.putString( charIDToTypeID( "jsMs" ), "undefined" );
executeAction( stringIDToTypeID( "AdobeScriptAutomation Scripts" ), desc4, DialogModes.NO );
};
/* btn1.onClick = function() {
w.close();
};*/
w.show();
};
SimpleDialog();
Copy link to clipboard
Copied
And …?
Copy link to clipboard
Copied
hi thaks for your greet help iit warks
i am greatfull for your help thank you so much
Copy link to clipboard
Copied
sorry for replay late

