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

Button in plugin running JSX action

Explorer ,
Apr 03, 2025 Apr 03, 2025

I im making simple plugin with buttons which can run photoshop actions, (removeBgBtn) works correct but two another button wont run, there is no error in logs. I have folder scripts and inside I have two jsx scripts. They works correct when I use classic action panel.

 

document.addEventListener("DOMContentLoaded", () => {
    const removeBgBtn = document.getElementById("remove-bg-btn");
    const smartBtn = document.getElementById("smartBtn");
    const classicBtn = document.getElementById("classicBtn");

    if (removeBgBtn) {
        removeBgBtn.addEventListener("click", async () => {
            console.log("Button clicked! Starting background removal process...");

            try {
                await remove_background();
                alert("Background removed successfully!");
                console.log(":white_heavy_check_mark: Background removed successfully!");
            } catch (error) {
                console.error(":cross_mark: Error removing background:", error);
                alert("Failed to remove background: " + (error.message || "Unknown error"));
            }
        });
    }

    if (smartBtn) {
        smartBtn.addEventListener("click", async () => {
            await runJSXScript("scripts/smart.jsx");  // Ensure the correct script path is used
        });
    }

    if (classicBtn) {
        classicBtn.addEventListener("click", async () => {
            await runJSXScript("scripts/classic.jsx");  // Ensure the correct script path is used
        });
    }
});
TOPICS
Actions and scripting , SDK , Windows
118
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
Enthusiast ,
Apr 03, 2025 Apr 03, 2025

Unfortunately Adobe is limiting the use of jsx, Keep in mind that to use jsx you have to set the manifest 4 and remove api 2. You could do it like this; Create an action that calls the jsx file, Then create another action that calls the previously created action. Create a button in the uxp panel that calls the action and it should work. That said, keep in mind that Adobe should soon stop supporting jsx, so I would go straight to uxp.

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 ,
Apr 03, 2025 Apr 03, 2025

So soon actions in JSX will stop working? Wtf? I have most important automatisation scripts there 😮 

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
Enthusiast ,
Apr 03, 2025 Apr 03, 2025

I tried to advise you,
but know that adobe has been thinking for a long time about removing jsx from photoshop,
so all cep and jsx panels will no longer be supported.
there is no certain date, but this is what he said to do.

my advice is to use the effort to convert your jsx scripts to uxp.

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 ,
Apr 03, 2025 Apr 03, 2025

it would be a huge problem probably for a lot of people, I don't understand what's bothering them. Unless they have a better solution to create automation in photoshop in a simple way.

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
Enthusiast ,
Apr 03, 2025 Apr 03, 2025

In fact the solution is uxp. As I told you there is no specific date, So it can be in 1 month, 6 months 1 year or even more.

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
Enthusiast ,
Apr 04, 2025 Apr 04, 2025
LATEST

@sttk3

 

I found this script that calls a jsx file by inserting the file path

/**
  * @File Execute ExtendScript from UXP Script
  * https://forums.creativeclouddeveloper.com/t/how-to-call-a-jsx-file-from-a-psjs-file/
  * https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-call-a-jsx-file-from-a-psjs-file/td-p/15193966
  * @Version 1.0.0
  * @author sttk3.com
*/

const { localFileSystem } = require('uxp').storage ;
const { app, core, action } = require('photoshop') ;

const jsxFile = await localFileSystem.getEntryWithUrl('/Users/username/Desktop/alert.jsx') ;
const token = await localFileSystem.createSessionToken(jsxFile) ;

try {
  await core.executeAsModal(async () =>
    {
      await action.batchPlay(
        [
          {
            _obj: 'AdobeScriptAutomation Scripts',
            javascript: {
              _kind: 'local',
              _path: token
            },
          }
        ], 
        
        {}
      ) ;
    }, 
    
    {
      commandName: 'ExtendScript', 
      interactive: true, 
    }
  ) ;
} catch(e) {
  await app.showAlert(e) ;
}

 

 

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