• 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 Script UI Palette(s) Based Script without using jsx Launcher ?

Enthusiast ,
Aug 01, 2021 Aug 01, 2021

Copy link to clipboard

Copied

Hi Experts,

Every time i need to launch my Palette Based Script i need to call it from a Launcher (Here i Have 2 Palettes)  :

 

//---------------------------------------------------------
//Making Palettes Windows
//---------------------------------------------------------
#targetengine "session1";
//#target InDesign 
var w = new Window("palette", {independent:true});
var gqmanager = new Window("palette");
................................................etc

 

So I need another Script to Launch My Main Script, and I wrote the Launcher as following (and save it as jsx file beside the jsxbin of my script :

 

//-------------------------------------------------------
// 'Script JSXBIN Launcher
//-------------------------------------------------------

  
// 1. My persistent engine (if needed)
#targetengine "session1";
 
// 2.My jsxbin code as a literal string in evalFile
$.evalFile(File($.fileName).path + "/" + escape("FGAS1460.jsxbin"));



 

 

So my Final Script Look Like the following :

Launcher.jpg

but some one told me i can get rid from it? but i didn't understand him, he actually wrote the solution in shape of C++ , so it was hard to understand! ?, please help me in simple way , this will be much easier in distributing the script. Thanks all in Advance.

Best
Mohammad Hasanin
TOPICS
Scripting

Views

489

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 2 Correct answers

Community Expert , Aug 01, 2021 Aug 01, 2021

Hi @M.Hasanin,

How about creating a menu entry via a startup script which on click launches your palette. You can search the forum for menu creation samples.

-Manan

Votes

Translate

Translate
Enthusiast , Aug 02, 2021 Aug 02, 2021

Thanks a lot @Manan Joshi   for your reply, but i need something more simple to final user, the problem is not me, i accept the launcher , in the end i found this method and it works :

Launcher_jsxbin.jpg

you can read more information here :

https://www.indiscripts.com/post/2010/04/binary-javascript-embedment-cs4-cs5 

 

Votes

Translate

Translate
Community Expert ,
Aug 01, 2021 Aug 01, 2021

Copy link to clipboard

Copied

Hi @M.Hasanin,

How about creating a menu entry via a startup script which on click launches your palette. You can search the forum for menu creation samples.

-Manan

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
Enthusiast ,
Aug 02, 2021 Aug 02, 2021

Copy link to clipboard

Copied

Thanks a lot @Manan Joshi   for your reply, but i need something more simple to final user, the problem is not me, i accept the launcher , in the end i found this method and it works :

Launcher_jsxbin.jpg

you can read more information here :

https://www.indiscripts.com/post/2010/04/binary-javascript-embedment-cs4-cs5 

 

Best
Mohammad Hasanin

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 ,
Aug 02, 2021 Aug 02, 2021

Copy link to clipboard

Copied

So instead of using eval you used doScript instead, how does this make a difference to the end user except eliminating an entry for her/him in the scripts panel. This is all related to script developer in my assessment and if the extra entry is the matter of concern for your user, then you could have placed the FGAS1460.jsxbin script outside the script panel's hot folder as you are already referring the script file using its path so you can refer whichever file you want.

Do let me know if I am still misinterpreting what is needed.

-Manan

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
Enthusiast ,
Aug 02, 2021 Aug 02, 2021

Copy link to clipboard

Copied

Hi @Manan Joshi , 

Thanks a lot for your feedback, The Main Problem (that) the end Script (jsxbin) is Palette Based Script, So it need targetengine to run, in my past test I usually distribute only two files to the final user (one is the Launcher.jsx) and the other one is (script.jsxbin) so i used eval to call the script file(*.jsxbin), but with this method i only use one file (*.jsxbin) with (doScript) to the final user (Short Example here) :

 

//-------------------------------------------------------
// M.Hasnain JSXBIN Palette Script Based Launcher
//-------------------------------------------------------
  
// 1. My persistent engine (if needed)
#targetengine "session1";

//2. Paste the jsxbin code as a literal string in doScript
app.doScript("@JSXBIN@ES@....etc");

 

Please see the video , i demonstrate the operation here :

https://drive.google.com/drive/folders/17IucZko2WbtECb-9v_nQtfB0ArSSMQT3?usp=sharing 

Best
Mohammad Hasanin

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
Enthusiast ,
Aug 02, 2021 Aug 02, 2021

Copy link to clipboard

Copied

LATEST

Hi @Manan Joshi 

also Marc Autret new Solution (2021) is the folowing (he wroted by himself) :

"A crucial fact about the palette type (versus dialog) is that any instance of such Window object must have a persistent reference in memory. Having a targetengine directive is a requirement, but you also need to store the result of new Window('palette', etc) in a non-local variable. Otherwise the palette is automatically destroyed when the identifier is out of scope. A solution is to return that reference (from the function that builds the UI) and to store it as a static property of some persistent object, e.g your main function", and here is his demonstration to try :

https://gist.github.com/indiscripts/7137d475edc68bdded3bb15abd770987#file-interactingpalettesexample... 

but actually i don't understand or imagine this method,, i tried already with no success,  this method will make you export directly to (jsxbin) with palettes and with no problem!, if you succeed in this method and can provide more direct example it will be good for everybody because he kind of (C++) man, its my first time ever see javascript code written in this way!  , i still try to learn new skills everyday, and thanks in advance.

Best
Mohammad Hasanin

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