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

How to run illustrator script from VS Code (Visual Studio Code)

New Here ,
Nov 20, 2022 Nov 20, 2022

Copy link to clipboard

Copied

A Google search will bring up many extensions with half-baked instructions on how to use them.

 

What is the definitive extension for running illustrator scripts in VS Code?

 

And where can I get full instructions on setting up and using it?

TOPICS
Scripting

Views

2.2K

Translate

Translate

Report

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

correct answers 1 Correct answer

Adobe Employee , Nov 21, 2022 Nov 21, 2022

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 20, 2022 Nov 20, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 ,
Nov 20, 2022 Nov 20, 2022

Copy link to clipboard

Copied

Hi @default30a91r3twkdw, once you have read the instructions on the ExtendScript Debugger install page that @Charu Rajput linked to, see if it helps to have a look at my own set-up. (I'm using MacOS; if you are using Windows, change the keybindings accordingly.)

 

This is my launch.json for Illustrator scripting:

{
    "type": "extendscript-debug",
    "request": "attach",
    "name": "Start debugger—AI",
    "hostAppSpecifier": "illustrator",
    "engineName": "main",
}

It uses the "attach" request, which means you start the debugger once, and then when you run your scripts from VSCode it uses the same debugger instance.

 

I also have these in my user settings.json file, just to tailor my IDE the way I prefer:

"debug.console.closeOnEnd": true,
"debug.internalConsoleOptions": "neverOpen",
"debug.openDebug": "neverOpen",
"debug.toolBarLocation": "docked",

 

And last, but not least, I have these in my keybindings.json file:

{
    "key": "f5",
    "command": "-workbench.action.debug.start",
    "when": "debuggersAvailable && debugState == 'inactive'"
},
{
    "key": "cmd+r",
    "command": "extension.extendscript-debug.evalInAttachedHost",
    "args": {
        "debugLevel": 1,
        "bringToFront": false
    }
},
{
    "key": "cmd+shift+r",
    "command": "extension.extendscript-debug.evalInAttachedHost",
    "args": {
        "debugLevel": 1,
        "bringToFront": true
    }
},
{
    "key": "cmd+.",
    "command": "extension.extendscript-debug.haltInHost",
    "when": "inDebugMode",
},
{
    "key": "ctrl+.",
    "command": "workbench.action.debug.stop",
    "when": "inDebugMode"
},

I use cmd+r to run a script without activating the host app (eg. if I just want to watch the console or debugger), and cmd+shift+r if I want to activate the host app (note that your scripts may activate the host app anyway if they show a dialog etc).

 

Well that's my set-up. I hope it gives you some idea of how to customize it to your preferences.

- Mark

Votes

Translate

Translate

Report

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 ,
Sep 28, 2023 Sep 28, 2023

Copy link to clipboard

Copied

Hi @m1b, i copied your launch.json. When i'm on a script and press F5 it asks me if i want to launch or attach, then it asks me if i want it to be used on Photoshop or Illustrator and finally it asks me to choose between main and transient. Since i will always need to launch on Illustrator on main.. is there a way to skip all these steps and execute the script just by pressing F5? Or at least to skip as much steps as possible..

 

Thanks!

Votes

Translate

Translate

Report

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 ,
Sep 28, 2023 Sep 28, 2023

Copy link to clipboard

Copied

LATEST

Hi @Kangi Sportswear, I have updated my ExtendScript launch.json configuration a little after this thread. Here is my current one:

{
    "type": "extendscript-debug",
    "request": "attach",
    "name": "Attach--v27",
    "hostAppSpecifier": "illustrator-27.064",
    "engineName": "transient",
    "hiddenTypes": [
        "builtin",
    ],
},

 

As you can see, I specify an engineName now. I recommend using the hiddenTypes property, too—it hides a lot of irrelevent mess in the debugger output.

 

Now to your question: if the debugger is asking for which app (and which engine) then perhaps your hostAppSpecifier isn't right, or isn't specific enough. For example, if you have two versions of Illustrator or Photoshop, the debugger won't know which to attach-to if the hostAppSpecifier is simply "illustrator" or "photoshop". Try adding the version (eg. 27 for Illustrator) then a decimal point, then 064 (meaning 64 bit architecture).

 

To make things convenient for me, I've set up key bindings to do things like "attach to host". Here are mine:

{
    "key": "alt+cmd+.",
    "command": "workbench.debug.panel.action.clearReplAction"
},
{
    "key": "ctrl+alt+cmd+a",
    "command": "workbench.action.debug.stop",
    "when": "inDebugMode"
},
{
    "key": "ctrl+alt+cmd+a",
    "command": "workbench.action.debug.run",
    "when": "debuggersAvailable && debugState == 'inactive'"
},
{
    "key": "cmd+r",
    "command": "extension.extendscript-debug.evalInAttachedHost",
    "args": {
        "debugLevel": 1,
        "bringToFront": false
    }
},
{
    "key": "cmd+shift+r",
    "command": "extension.extendscript-debug.evalInAttachedHost",
    "args": {
        "debugLevel": 1,
        "bringToFront": true
    }
},
{
    "key": "cmd+.",
    "command": "extension.extendscript-debug.haltInHost",
    "when": "inDebugMode"
},
{
    "key": "ctrl+.",
    "command": "workbench.action.debug.stop",
    "when": "inDebugMode"
},

So I have a key to attach—which I need only after restarting the host app or the debugger—and another to run the active script—which I use *a lot*. Hope that helps.

- Mark

Votes

Translate

Translate

Report

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 Employee ,
Nov 21, 2022 Nov 21, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 ,
Nov 21, 2022 Nov 21, 2022

Copy link to clipboard

Copied

Thanks @erinferinferinf that is helpful. I didn't know about the "excludes" property of the launch configuration.

Votes

Translate

Translate

Report

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