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
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
Copy link to clipboard
Copied
oh my god~
I'm sorry
Copy link to clipboard
Copied
A great man to help me, I will appreciate you very much!
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();
}
Copy link to clipboard
Copied
You want to check app.activeScript
Copy link to clipboard
Copied
I don't understand, help me
Copy link to clipboard
Copied
if(app.activeScript.name != "AAA.jsx"){
alert("You changed the script name!");
exit();
}
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
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.....
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"))
Copy link to clipboard
Copied
I am sorry,
I don't know.
How to combine this with Harbs Provide together
Thank you~
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();
}
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?
Copy link to clipboard
Copied
Try this:
Copy link to clipboard
Copied
Name or not, will still pop the script name, the same script will run
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
Can't get Result value to a variable, and then to app.activeScript.name?
Copy link to clipboard
Copied