Copy link to clipboard
Copied
Here's the sample Applescript code I came up with using the scripting guide/reference for CS6 and also doing some online searches:
tell application "Adobe Illustrator"
activate
delay 10
set pfilepath to "/Users/username/Documents/Temp/someFile.ai"
set pfile to POSIX file pfilepath
open pfile as alias without options
delay 10
do javascript "#include '/Users/username/Documents/Temp/someScript.jsx'"
delay 1
quit
end tell
I just want to open the app (sample here for AI but also nice to do same for Photoshop), open a file, then run ExtendScript file against it, then close after processing. With this sample script, all that works is the app launches. No file opened, no script ran, app doesn't close at end. I see no errors pop up nor anything show up in command prompt.
The sample ExtendScript just triggers an alert popup message for testing
Also to note, the Applescript snippet is executed from Python but I believe where/how it's executed shouldn't matter (except maybe where the error messages might show up). Although in worse case, I'll debug/run through the AppleScript editor.
Any tips on what's wrong here? Or does it look technically correct?
1 Correct answer
Explore related tutorials & articles
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Are you writing the cross-platform Python application?
Copy link to clipboard
Copied
Yes, indeed. On Mac, Python executes the Applescript. On Windows, it invokes the Adobe COM API (in Python rather than the default suggested VBScript). Supposed to be a generic command line script launcher for executing javascript ExtendScripts w/o manually opening/dealing w/ the Adobe apps as well as being able to open a document before executing script as needed for scripts that expect to work against active documents.
Copy link to clipboard
Copied
Good stuff, do you have any documentation you can tell me which is for preferably, beginners, that accomplishes a similar setup using the Python? And, is this because some users use a Mac and others use the PC for Adobe apps within the organization?
Copy link to clipboard
Copied
No, I don't have specific documentation, but you can put together such for Python from bits & pieces here & there. And yes, I made it cross-platform to anticipate Adobe users on both Mac & PC, for which there currently are, though for what we're doing skews towards Windows for now.
For the COM API, follow the VBScript reference and code samples. Just convert the method calls to Python COM. There will be slight syntax differences sometimes (e.g. add "()" to method call for VBScritp subroutines that don't need them, etc.). The scripting guide link below should have code samples for VBScript.
For example of Python COM, you can search online, or look at AutoItDriverServer/server.py at master · daluu/AutoItDriverServer · GitHub, which may be bit much/complex for you? For Python COM, you either need ActivePython or regular Python plus Python for Windows Extensions (e.g. pywin32).
For Applescript and Python, this post might be useful: osx - Calling AppleScript from Python without using osascript or appscript? - Stack Overflow
for the rest of the the cross-platform support, it's just generic python to parse command line arguments, etc. You may want to query what platform the script is running under using some standard Python modules (os, system). An example can be found in AutoPyDriverServer/server.py at master · daluu/AutoPyDriverServer · GitHub
Hope that helps.

