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?
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
...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)
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!
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
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.
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.
Copy link to clipboard
Copied
Wow, thanks for all the tips and code Silly-Vā!!!! I really appreciate it!
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.