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

Extendscript Toolkit: Stop from returning to ESTK after compiling/running JSX?

Engaged ,
May 07, 2016 May 07, 2016

Copy link to clipboard

Copied

Hello,

Latest version of Illy on a Mac OS X.

When I execute JSX files in ESTK, then Illustrator will come into focus … But then, the ESTK application comes back into focus.

I want to stay in Illustrator after running a script from ESTK. Is this possible?

TOPICS
Scripting

Views

923

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

Community Expert , May 08, 2016 May 08, 2016

mickyhulse schrieb:

… I want to stay in Illustrator after running a script from ESTK. Is this possible?

I would say: no chance.

If I understand you right:

You opened a script in STK and then you start the script directly from ESTK?

ESTK is the ("main-") app you started from. Illustrator (mostly) comes to front while running scripts out of ESTK (if Illustrator is the target in the script). But when the script is finished, the focus always comes back to the ("main-") app --> ESTK.

Can you say me: what i

...

Votes

Translate

Translate
Adobe
Community Expert ,
May 08, 2016 May 08, 2016

Copy link to clipboard

Copied

mickyhulse schrieb:

… I want to stay in Illustrator after running a script from ESTK. Is this possible?

I would say: no chance.

If I understand you right:

You opened a script in STK and then you start the script directly from ESTK?

ESTK is the ("main-") app you started from. Illustrator (mostly) comes to front while running scripts out of ESTK (if Illustrator is the target in the script). But when the script is finished, the focus always comes back to the ("main-") app --> ESTK.

Can you say me: what is the reason for your question?

(I think you know that you can start scripts furthermore directly from Illustrator or double clicking on the *.jsx)

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
Engaged ,
May 08, 2016 May 08, 2016

Copy link to clipboard

Copied

Thank you for the reply and answer pixxxel schubser​, I really appreciate it!

You opened a script in STK and then you start the script directly from ESTK?

Yup, that's correct.

ESTK is the ("main-") app you started from. Illustrator (mostly) comes to front while running scripts out of ESTK (if Illustrator is the target in the script). But when the script is finished, the focus always comes back to the ("main-") app --> ESTK.

Ahhh, that makes a lot of sense.

At the top of all my scripts I put:

#target illustrator

#targetengine main

Stupid question, but what does "#targetengine main" do (or, what is it for, and why is it good practice to have this line of code in a script)? Could I say "#targetengine illustrator"?

Can you say me: what is the reason for your question?

(I think you know that you can start scripts furthermore directly from Illustrator or double clicking on the *.jsx)

I've always found it kinda annoying that the script will run, but then jump back to ESTK.

Good point about double-clicking and running from Illy directly.

The way I work currently, for development, is to use Atom IDE to write my JSX, then I jump to ESTK to "run" the script. All I use ESTK for is to press the "play" button so I can test the script. I really don't use ESTK for anything else (except for the occasional API lookup).

Thanks again for your help pixxxel schubser​! Have an excellent day!

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 ,
May 08, 2016 May 08, 2016

Copy link to clipboard

Copied

You're welcome.

You are totally right. For development it is much more better to run scripts from ESTK.

One note:

I you want to stay a little bit in Illustrator after running a script - create (temporary) a (last) line in your code with an alert("done"); Now you can see the result (but nothing else, unfortunately) and stay in Illustrator till you press the OK button.

Have fun

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
Engaged ,
May 08, 2016 May 08, 2016

Copy link to clipboard

Copied

Oooh, awesome tip! I'll give that alert thing a try.

Thank you again pixxxel schubser​! I greatly appreciate your help.

Have a great rest of your day.

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
Valorous Hero ,
May 09, 2016 May 09, 2016

Copy link to clipboard

Copied

I had a hunch you could do something wacky and crazy, as per standard mandatory Illustrator scripting procedure, so I figured why not try to cheat it with a $.sleep. I suppose it depends on how long your scripts run for, but I was able to bring AI back up with a sleep of 500, while values of 50 and 100 were apparently too short.

#target illustrator

function test(){

  var doc = app.activeDocument;

  var t = doc.textFrames.add();

  t.contents = "Test!";

  t.left = Math.random() * doc.width;

  t.top = -Math.random() * doc.height;

  var bt = new BridgeTalk;

  bt.target = "illustrator";

  bt.body = '$.sleep(500);BridgeTalk.bringToFront("illustrator");';

  bt.send();

};

test();

This worked on Windows.

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
Engaged ,
May 10, 2016 May 10, 2016

Copy link to clipboard

Copied

LATEST

Wow, thanks for all the tips and code Silly-V​!!!! I really appreciate it!

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
Valorous Hero ,
May 09, 2016 May 09, 2016

Copy link to clipboard

Copied

In my workings, I have used "#targetengine main" because I thought that my palettes were disappearing instantly and putting this in is how that became fixed. However, later I also determined that having it or not having it will allow or prevent access from the global variables created by other scripts which I had used the ESTK to launch. You can also try and test this by launching a test script from ESTK and creating some global variable. Then run another script that looks for that variable, but do not use #targetengine and do not run it from the ESTK; instead use File > Other Scrtips menu item. It is my guess you shall get an error as the variable is not defined. Now put the targetengine line back into the test script and launch again without ESTK: you should see the script has access to that variable.

Since that time, I've been testing my scripts from as many calling mechanisms as possible including from ESTK, from File > Other Scripts and from my script-panel, being careful to include any items and only using the targetengine for palettes - as I still think that they disappear without it - no longer sure though.

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