将 AppleScript 转换为 Python appscript (`do javascript`)
这是 AppleScript 模板:
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
我想将其转换为 Python appscript。不幸的是,我不知道如何翻译do javascript
。有什么想法吗?
我什至不知道如何找到它。也许我对 AppleScript 的了解太少了。 do
是关键字吗?或者这是我发送给应用程序的命令? javascript
是 do
的参数吗?或者 do javascript
属于一起吗(作为带空格的命令)?
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要将通用
AppleScript
转换为appscript
,请使用appscript
网站上提供的ASTranslate
工具 此处。由于某些应用程序的脚本定义中的怪癖和错误,它并不总是能够成功翻译,但它是一个很好的起点。To translate generic
AppleScript
toappscript
, use theASTranslate
tool available from theappscript
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.我仍然不完全知道如何翻译上面的内容(更一般地说:我不知道如何将任何通用的 AppleScript 代码翻译为 Python appscript)。
然而,对于上面的情况,我发现有命令
do_javascript
。它似乎并不执行文件,而是直接执行给定的 JS 代码字符串。例如,这有效:
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.E.g., this works: