floorish
Explorer
floorish
Explorer
Activity
‎Sep 07, 2021
05:14 AM
I'm trying to change the text size of the currently selected text frame(s). This works fine if a certain range of text is selected or if a full text frame is selected, but I'm running into issues if the currently selected text is empty, i.e. when there is an insertion point. (In that case the full text frame size should be changed.) If the cursor is at a certain position inside a text frame without any selection Illustrator will return an invalid range of text. Getting any property of this selection will give an "Invalid range" error. Even getting the class of the current selection. tell application id "com.adobe.illustrator"
set selectedItems to selection of current document
set selectedClass to class of selectedItems
-- if current selection is an insertion point this will throw an error
-- "Adobe Illustrator got an error: Invalid range."
if selectedClass is text then
-- user selected a text range
set size of selectedItems to 26
else
-- user selected text frames
repeat with selectedItem in selectedItems
set size of selectedItem to 26
end repeat
end if
end tell Is there anyway I can determine if the current selection is an insertion point, such that I can target the container text frame instead to set the point size of the entire container? According to the Illustrator Applescripting guide: "When there is an active insertion point in the contents of a text frame, selection returns a reference to the insertion point." Instead it returns something like: text from character 2 to character 1 of story 1 of document 1 Which has an incorrect range.
... View more
‎Sep 01, 2021
02:43 AM
Thanks, I can also confim it's fixed in 16.4
... View more
‎Sep 01, 2021
02:43 AM
Looks like this is fixed in InDesign 16.4 It includes an empty NSAppleEventsUsageDescription key in its info.plist, therefore the permission dialog to communicate with other apps does show up again.
... View more
‎Aug 27, 2021
02:34 AM
1 Upvote
Yes, it should.
... View more
‎Aug 27, 2021
02:15 AM
In that case the user is the one executing the script. So this will work: tell application id "com.adobe.InDesign"
tell application "Finder" to display dialog "Hello"
end tell But this won't: tell application id "com.adobe.InDesign"
do script "tell application \"Finder\" to display dialog \"Hello\""
end tell Because then it's still InDesign executing the inner part and InDesign needing permission to communicate with Finder.
... View more
‎Aug 27, 2021
02:08 AM
1 Upvote
When you change the plist the signature of the app will be different, which means macOS won't launch the app because it has been tampered with. Changing the plist is not a solution for end-users, Adobe needs to add the key and distribute it in an update (that is signed by Adobe). If you want to change it manually you will need to resign the app using a custom made signing certificate. You can create a custom certificate in Keychain and use that to sign the app with `codesign`. Pretty technical, so I don't recommend doing that if you're not familiar with these tools. I'm not sure if the signature will be valid again if you remove the key, so your best bet is to just reinstall InDesign. If you need InDesign to work for a specific app follow these instructions: 1. uninstall the 16.3.2 version with changed plist 2. install older 16.2 3. run your script that communicates with an external app (for each app you'll need to communicate with) 4. give permission when macOS asks for it 5. install 16.3.2 The permission given in step 4 is persistent, so it keeps working in 16.3.2.
... View more
‎Aug 26, 2021
08:16 AM
That's a very interesting workaround. It does seem to work, but it gives a slightly different permission than without `do shell script`. tell application id "com.adobe.InDesign"
set subcommand to "osascript -e \\\"tell application \\\\\\\"Finder\\\\\\\" to display dialog \\\\\\\"Hello, World!\\\\\\\"\\\""
do script "do shell script \"" & subcommand & "\""
end tell This correctly shows the permission dialog and it adds Finder to the Automation settings. But it does not actually give InDesign permission to communicate with Finder directly. So the following still gives an error even after running the above and giving permission: tell application id "com.adobe.InDesign"
do script "tell application \"Finder\" to display dialog \"Hello, World!\""
end tell So you'd have to wrap all commands in a `do shell script` invocation indeed. Just doing it once to trigger the permission is not enough.
... View more
‎Aug 20, 2021
05:38 AM
You can't manually add permissions, InDesign should automatically pop up the permission dialog. That's what's not working 😉
... View more
‎Aug 19, 2021
01:34 AM
Check System Preferences > Security & Privacy > Privacy > Automation. InDesign will likely have a checkmark for Photoshop on your Mac, because you've used that script in the past with InDesign <16.3.2 It happens when communicating to any app. It's a macOS security feature that InDesign 16.3.2 doesn't implement. See my original post for a solution. The checkmarks in Automation are persistent, so you can go back to 16.2 -> run the scripts to trigger the permission dialog -> upgrade to 16.3.2 and your scripts will continue to work.
... View more
‎Aug 14, 2021
03:06 AM
1 Upvote
Sorry if I wasn’t clear in my previous posts. The issue is app to app communication. The ‘do script’ command is just an example to trigger that. In your example InDesign triggers an InDesign dialog. Of course Indesign is allowed to control itself, that could not do any harm. But Indesign controlling other apps, that might have some risks. A malicious app might get access to your files, photos etc. by running a script. Doesn’t matter it it’s calling Finder, Photos, Calendar, whatever. An app telling another app what to do is a security risk. Therefore macOS asks explicit user consent whenever an app runs a script that tells another app to do something. If the user gives consent all is good and the app can control the other app. If the user does not give consent you’ll get an error: permission is denied. Now in 16.3.2 this permission dialog is never triggered. That means the user cannot give explicit consent. Therefore the script will always return a permission denied error. The ‘do script’ command makes sure it’s InDesign thats running the script. This is the same when running a script with an event handler. InDesign is the one that runs the script, so the user must give permission to allow InDesign to communicate with other apps. The issue is not with 'do script' per se, nor is it with calling Finder. It's that InDesign 16.3 is not allowed to control other apps. 16.2 does correctly trigger the permission dialog, while 16.3 doesn’t. I believe this is due to NSAppleEventsUsageDescription, which is now required by macOS to be able to communicate between apps using scripting. Hope this clears up the issue.
... View more
‎Aug 14, 2021
03:05 AM
These macOS automation permissions are here since Mojave, so I indeed expect the same errors on macOS Mojave 10.14 and Catalina 10.15. Your example works because it’s the user that calls the script, not InDesign. It’s not a replacement of the ‘do script’ example I’ve posted above. In your case there is no app to app communication, so naturally that is allowed.
... View more
‎Aug 12, 2021
04:53 AM
Just to answer your question—yes, your example works fine when executed directly, because in that case it's not InDesign that's running the inner part, but the user. The user is running the full script, who is naturally allowed to do this. It unfortunately doesn't solve the case where InDesign runs a script. Then the user must give permission first, but that is never asked in 16.3.2
... View more
‎Aug 12, 2021
04:43 AM
Thanks Rob, The do script command is an example which conveniently shows the issue. My script is actually called from an event listener which in turn tells Finder directly to show the dialog. But the effect is the same, i.e. InDesign launches an AppleScript which tells another application to do something. Since InDesign is the caller of the script (either with do script or after event trigger), it must have user permission to tell the external app to do something. This permission is never asked in 16.3.2 After adding NSAppleEventsUsageDescription to the plist, both do script and when called from an event handler work correctly and ask for permission. Example Adding the event listener: tell application id "com.adobe.InDesign"
set scriptPath to "/path/to/other.scpt"
make event listener with properties {event type:"afterOpen", handler: scriptPath}
end tell which calls /path/to/other.scpt: on run (argv)
tell application "Finder"
activate
display dialog "Hello"
end tell
end run
... View more
‎Aug 12, 2021
02:33 AM
1 Upvote
Not sure if this is the correct place to post this, but the uservoice forums seems kind of silent. I’m using the InDesign do script AppleScript command to instruct another application to do something. Since 16.3 this doesn’t work anymore, because macOS prevents the script from running. Previous versions of InDesign worked fine, after the user allowed InDesign to control the target app. Use case: I’m the developer of a font manager and want InDesign to report which fonts are used in a document macOS version: 11.3.1 InDesign version: 16.3.2 Steps to reproduce: Reset the macOS Apple Event permissions for InDesign in Terminal: tccutil reset AppleEvents com.adobe.InDesign 2. Run the following AppleScript: tell application id "com.adobe.InDesign"
do script "tell application \"Finder\" to display dialog \"Hello\""
end tell Expected: 1. macOS asks to allow InDesign to control Finder 2. After confirming, Finder shows an alert Actual: AppleScript error: Not authorized to send Apple events to Finder. (-1743) Background info: InDesign versions before 16.3 worked fine. I’ve been using do script to communicate with my app without issues. When running the script the first time macOS will ask the user to allow InDesign to control my app. After confirming or dismissing this dialog a new entry in System Preferences > Security & Privacy > Automation will show up for Adobe InDesign 2021.app If the Automation entry is checked communication is authorised and the script works fine. If the user did not allow control, the entry is unchecked and can be enabled at any moment by the user in System Preferences > Security & Privacy > Automation. Since InDesign 16.3 the macOS permission dialog doesn’t show up anymore. The user is not asked to give permissions and the entry will never show up in Automation. This results in all scripts failing due to no authorisation to communicate with external apps. If the user had previously allowed control (e.g. using InDesign 16.2), the Automation permission is persistent and works for 16.3 as well. But if it’s a first-time user, or if the Automation permission is reset, InDesign 16.3 will never trigger the dialog anymore. To reset macOS Apple Event permissions run the following command in Terminal: tccutil reset AppleEvents com.adobe.InDesign Solution: Looks like adding NSAppleEventsUsageDescription to the InDesign Info.plist solves the issue. Once this key is added the macOS permission dialog will show up correctly again. I’ve successfully confirmed this by adding this key to the plist: plutil -insert NSAppleEventsUsageDescription -string "This script needs to control other applications to run." /Applications/Adobe\ InDesign\ 2021.app/Info.plist And resigning the .app using a custom signing certificate (changing the Info.plist will break the original signing). According to https://indiestack.com/2018/08/apple-events-usage-description/ this key is required when linking against the macOS 10.14 SDK. Perhaps that’s what has changed in 16.3? If you need any further information to reproduce this issue, or information about the solution please let me know. Cross post: https://indesign.uservoice.com/forums/913162-adobe-indesign-sdk-scripting-bugs-and-features/filters/new
... View more