Skip to main content
Known Participant
July 23, 2025
Answered

Floating panel to run script

  • July 23, 2025
  • 1 reply
  • 496 views

Hello, would be happy if someone may point out how to run a script from a floating panel button. 

below fails to be able to run the script once the button is hit. 

 

The script it is talking to runs perfectly fine on its own, but the button script is failling to call it correctly. 

 

The script says there is no document but i have one open...

 

Many thanks 

 

Smyth 

//@target illustrator
//@targetengine "persistent"
//@strict on

// Suppress warning
app.preferences.setBooleanPreference("ShowExternalJSXWarning", false);

var win = new Window('palette', 'Run Custom Script', undefined, { closeButton:true });
win.alignChildren = ['fill', 'top'];

var runBtn = win.add('button', undefined, 'Run Grids V2.jsx');
runBtn.onClick = function() {
    var scriptPath = "C:/Program Files/Adobe/Adobe Illustrator 2021/Presets/en_US/Scripts/Grids V2.jsx";
    var scriptFile = new File(scriptPath);
    if (!scriptFile.exists) {
        alert("Script not found at:\n" + scriptFile.fsName);
        return;
    }
    try {
        $.evalFile(scriptFile);
    } catch (e) {
        alert("Could not execute script:\n\n" + e);
    }
};

win.center();
win.show();

 

Correct answer m1b

Hi @SmythWharf, persistent floating palettes are more complicated to code than modal dialogs, because you need to communicate between Illlustrator and the palette in the same way you would communicate between Illustrator and, say, Photoshop... via BridgeTalk.

 

I wrote a demo script here showing a minimal set up. It is a palette that shows the currently selected raster item's scale and rotation. That should get you started.

- Mark

1 reply

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
July 23, 2025

Hi @SmythWharf, persistent floating palettes are more complicated to code than modal dialogs, because you need to communicate between Illlustrator and the palette in the same way you would communicate between Illustrator and, say, Photoshop... via BridgeTalk.

 

I wrote a demo script here showing a minimal set up. It is a palette that shows the currently selected raster item's scale and rotation. That should get you started.

- Mark

Known Participant
July 23, 2025

Hello, 

 

I see, I am afriad the link is not working. May this be updated.

 

Best, 

 

Smyth

m1b
Community Expert
Community Expert
July 23, 2025

Sorry! Fixed now.