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

ID Cs6: How to restrict the user to change the script file name

Advocate ,
Oct 06, 2014 Oct 06, 2014

Copy link to clipboard

Copied

I want to restrict the user to change the script file named, Otherwise, the script will not run.

example:The file name is AAA.jsx,  if you change to BBB.jsx,  It will can not run, And tip: "can not change the file name"

Thank you very much

TOPICS
Scripting

Views

869

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 ,
Oct 06, 2014 Oct 06, 2014

Copy link to clipboard

Copied

You already asked once today. Asking again,in a larger font with an annoying color, won't do you any good. People will refuse to help you next time.

As it is, you can check out   Adobe InDesign CS6 (8.0) Object Model JS: Application

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
Advocate ,
Oct 06, 2014 Oct 06, 2014

Copy link to clipboard

Copied

oh my god~

I'm sorry

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
Advocate ,
Oct 06, 2014 Oct 06, 2014

Copy link to clipboard

Copied

A great man to help me, I will appreciate you very much!

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
Advocate ,
Oct 07, 2014 Oct 07, 2014

Copy link to clipboard

Copied

some body say like this,but it is wrong

if(WScript.ScriptName.toLowerCase()!="aaa.jsx")

{

WScript.echo("Please don't change the js name");

WScript.Quit();

}

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
LEGEND ,
Oct 07, 2014 Oct 07, 2014

Copy link to clipboard

Copied

You want to check app.activeScript

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
Advocate ,
Oct 07, 2014 Oct 07, 2014

Copy link to clipboard

Copied

I don't understand, help me

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
LEGEND ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

if(app.activeScript.name != "AAA.jsx"){

alert("You changed the script name!");

exit();

}

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
Advocate ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

I love you, you are so great ~

Best wishes for you

Thank you very much~~

I was a little excited

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
Advocate ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

Sorry, I come back

When my file name contains Chinese, will prompt: "You changed the script name!"

My file name must contain Chinese.....

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
Guide ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

There is a problem with app.activeScript when run from ESTK, enclose your test with a try / catch clause.

To generate a string literal equivalent to the file name, use the following:

try {

    $.writeln(app.activeScript.name.toSource());

} catch( ex ) {

    $.writeln("Running from ESTK: "+File($.fileName).name.toSource());

}

"喜狼".toSource()

Result: (new String("\u559C\u72FC"))

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
Advocate ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

I am sorry,

I don't know.

How to combine this with Harbs Provide together

Thank you~

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
Guide ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

You just copy-paste the unicode string literal from the ESTK console output into your code.

If the file is named with your name, that would be:

if( app.activeScript.name != "\u559C\u72FC.jsx"){

     alert("You changed the script name!");

     exit();

}

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
Advocate ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

oh~my god~ I understand a bit, InDesign or TooKit don't know Chinese?

A bit complicated, can automatically do?

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
Guide ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

Try this:

  1. if( app.activeScript.name!="book_\u559C\u72FC.jsxbin" ) {
  2.   alert(app.activeScript.name.toSource());
  3. }

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
Advocate ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

Name or not, will still pop the script name, the same script will run

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
Advocate ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

LATEST

if( app.activeScript.name!="book_\u559C\u72FC.jsxbin" ) {

  alert(app.activeScript.name.toSource());

}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

the above with the below is same mistake:incognizant "book_喜狼.jsxbin" is "book_\u559C\u72FC.jsxbin"

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

if( app.activeScript.name != "\u559C\u72FC.jsx"){

     alert("You changed the script name!");

     exit();

}

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
Advocate ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

Can't get Result value to a variable, and then to app.activeScript.name?

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
Advocate ,
Oct 08, 2014 Oct 08, 2014

Copy link to clipboard

Copied

  1. Still not~~

  1. try
  2.     $.writeln(app.activeScript.name.toSource()); 
  3. } catch( ex ) { 
  4.     $.writeln("Running from ESTK: "+File($.fileName).name.toSource()); 
  5.  
  6. "book_喜狼".toSource() 

  7. --------------------------------------------------------------------------
  8. Result: (new String("book_\u559C\u72FC"))
  9. 喜狼 into the \u559C\u72FC,but "book_" Is still "book_"
  10. And I run "book_喜狼.jsxbin" still alert : You changed the script name!

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