Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Execute a script via a button

Explorer ,
Sep 30, 2023 Sep 30, 2023

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

}

TOPICS
Actions and scripting
792
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Explorer ,
Oct 01, 2023 Oct 01, 2023

any help pleas

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2023 Oct 02, 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]

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 02, 2023 Oct 02, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2023 Oct 02, 2023

hi photoshop

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 02, 2023 Oct 02, 2023

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.

ABAMBO | Hard- and Software Engineer | Photographer
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2023 Oct 02, 2023

thank you so much i post in correct forum.

thank you so much sir

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2023 Oct 02, 2023

Run the script from an Action.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2023 Oct 02, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 02, 2023 Oct 02, 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 );
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2023 Oct 02, 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();
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2023 Oct 03, 2023

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();
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2023 Oct 04, 2023

And …? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 04, 2023 Oct 04, 2023

hi thaks for your greet help iit warks

i am greatfull for your help thank you so much

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 04, 2023 Oct 04, 2023
LATEST

sorry for replay late 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines