Skip to main content
wael mohammedt42523860
Known Participant
October 1, 2023
Question

Execute a script via a button

  • October 1, 2023
  • 4 replies
  • 996 views

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();}

}

This topic has been closed for replies.

4 replies

c.pfaffenbichler
Community Expert
Community Expert
October 4, 2023

And …? 

wael mohammedt42523860
Known Participant
October 4, 2023

hi thaks for your greet help iit warks

i am greatfull for your help thank you so much

wael mohammedt42523860
Known Participant
October 4, 2023

sorry for replay late 

wael mohammedt42523860
Known Participant
October 2, 2023
 

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

c.pfaffenbichler
Community Expert
Community Expert
October 2, 2023
    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 );
wael mohammedt42523860
Known Participant
October 2, 2023

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();
}

 

wael mohammedt42523860
Known Participant
October 2, 2023

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]

 

 

Abambo
Community Expert
Community Expert
October 2, 2023

This is not a coding forum. Please tell us, what Adobe application you use and we will move the thread to the correct forum.

ABAMBO | Hard- and Software Engineer | Photographer
wael mohammedt42523860
Known Participant
October 2, 2023

hi photoshop

 

wael mohammedt42523860
Known Participant
October 1, 2023

any help pleas