This is the AppleScript template:
tell application "Adobe Photoshop CS5"
set theFile to alias “Application:Documents:MyFile” open theFile
do javascript (file <path to Emboss.jsx>) with arguments { 75,2,89 }
end tell
And I would like to translate that to Python appscript. Unfortunately, I cannot figure out how to translate the do javascript
. Any ideas?
I don't even know how to find it out. Maybe I know AppleScript too less. Is do
a keyword? Or is it a command I am sending to the application? Is javascript
a parameter of do
? Or does do javascript
belong together (as a command with a space)?
I still don't exactly know how to translate the above (and more generally: I don't know how to translate any generic AppleScript code to Python appscript).
However, for the above case, I found that there is the command do_javascript
. It doesn't seem to execute files though but rather executes the given JS code string directly.
Eg, this works:
from appscript import *
import os, sys
ps = app("Adobe Photoshop CS5")
filelist = sys.argv[1:]
jsCode = """
var g_StackScriptFolderPath = app.path + "/Presets/Scripts/"
var runMergeToHDRFromScript = true;
$.evalFile(g_StackScriptFolderPath + "Merge to HDR.jsx");
mergeToHDR.mergeFilesToHDR(%s, true);
""" % (repr(filelist),)
ps.do_javascript(jsCode)
To translate generic AppleScript
to appscript
, use the ASTranslate
tool available from the appscript
web site here . It is not always able to successfully translate due to the quirks and bugs in the script definitions of some applications but it is a good place to start.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.