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

AppleScript combined with app.doscript() gives a permission error

Explorer ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

Hi all,

We are trying to get an argument using applescript and following code gives us an error. The thing I should emphasize is, this error only occurs when our plugin is installed. (My company develops a InDesign plugin and this piece of code doesn't even interact with our scripting functions). I checked our script providers and all the related implementation. Couldn't find something that blocks AppleScript. Other applescript that we call through same mechanism, doesn't have this problem. Only this "item 1 of argument" part. Any pointer would be helpful.

Code:

function functionName(ourInputArg) {
    var inputArg = [ourInputArg];
	var myAppleScript = 'do shell script "echo " & item 1 of arguments'
	app.doScript(myAppleScript, ScriptLanguage.APPLESCRIPT_LANGUAGE, inputArg, UndoModes.FAST_ENTIRE_SCRIPT, "undo AppleScript");  
}

 Error:

Screenshot 2024-09-27 at 07.15.21.png

TOPICS
Scripting , SDK

Views

172

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 ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

and what exactly do you pass as ourInputArg? can you log item 1 of ourInputArg and see what it shows?

 

also shouldn't it be item 1 of our inputArg instead of item 1 of arguments?

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
Explorer ,
Sep 30, 2024 Sep 30, 2024

Copy link to clipboard

Copied

Hi @leo.r ,

Thanks for your response. Here's a working sample. It suppose to read the currently opened document name.  Error I'm getting is "Can't get 1 of Arguments. Access not allowed". Once I remove my plugin, this doesn't give an error

if(app.documents.length > 0){
		var myName = app.documents[0].name.substr(0,app.documents[0].name.lastIndexOf("."));
        myFunction(myName);
		}
else{
    alert("No documents are open");
}

function myFunction(ourInputArg) {
    var inputArg = [ourInputArg];
	var myAppleScript = 'display dialog item 1 of arguments'
	app.doScript(myAppleScript, ScriptLanguage.APPLESCRIPT_LANGUAGE, inputArg, UndoModes.FAST_ENTIRE_SCRIPT, "undo AppleScript");  
}


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
Community Expert ,
Sep 30, 2024 Sep 30, 2024

Copy link to clipboard

Copied

Does your plug-in provide its own AppleScript support for the plug-in functionality?

 

Also, do other calls to arguments (for example, count arguments, arguments as string, return arguments) return an error, or only when retrieving the items?

 

 

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 ,
Sep 26, 2024 Sep 26, 2024

Copy link to clipboard

Copied

If this error occurs only when the plugin in installed then I would say start by commenting out code in the plugin to identify which piece is causing this trouble and then we can discuss more with the specific information you uncover doing this.

-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
Explorer ,
Sep 30, 2024 Sep 30, 2024

Copy link to clipboard

Copied

Hi  @Manan Joshi ,

Thanks for the insight. Actually our plugin is way too big to be commented out. However, I put some debugging info on our plugin model's script providers. Tying to get some information from them. I'll post the updates here if I an uncover something.

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 ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

Hi @Kasun_Bamu , I don’t get the error. Maybe something about your MacOS version and the shell script. This also, works for me:

 

functionName("Hello World")
function functionName(ourInputArg) {
    var inputArg = [ourInputArg];
	var myAppleScript = 'display dialog item 1 of arguments'
	app.doScript(myAppleScript, ScriptLanguage.APPLESCRIPT_LANGUAGE, inputArg, UndoModes.FAST_ENTIRE_SCRIPT, "undo AppleScript");  
}

 

Screen Shot 24.png

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
Explorer ,
Sep 30, 2024 Sep 30, 2024

Copy link to clipboard

Copied

Hi @rob day ,

Thanks for your effort and response. But you shouldn't be getting the error though. This error only occurs when our plugin is installed. That's what I'm trying to figure out.

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 ,
Sep 30, 2024 Sep 30, 2024

Copy link to clipboard

Copied

What are you trying to do with AppleScript that can't be done with ExtendScript? Are you trying to communicate with other MacOS apps?

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 03, 2024 Oct 03, 2024

Copy link to clipboard

Copied

LATEST

Have a look at the ourInputArg argument - use a debugger and set a breakpoint at the ExtendScript side, or add this line before the app.doScript:

alert(inputArg.toSource());

On your second example - is the document already saved?

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