我是 applescript 甚至这个社区的新手,所以这个问题似乎很奇怪。如果是这样,我很抱歉。但是我在谷歌搜索中找不到答案。所以让我问一下。
当我运行代码时
tell application "Evernote"
set theNote to item 1 of selection
set theTitle to (title of theNote)
end tell
Run Code Online (Sandbox Code Playgroud)
我收到一个错误,说
/var/folders/fm/k76y42cs1y98bjwfyf951q1r0000gn/T/vbkvTSQ/55:47:53: execution error: Evernote got an error: Can’t make item 1 of selection into type specifier. (-1700)
Run Code Online (Sandbox Code Playgroud)
但如果我跑到下面
tell application "Evernote"
set theNote to (selection)
set theNote to item 1 of theNote
set theTitle to (title of theNote)
end tell
Run Code Online (Sandbox Code Playgroud)
我可以得到预期的结果。
为什么会发生这个错误?我看不到两个代码的区别。
Applescript 的暗示get再次罢工!!
尝试这样做:
tell application "Evernote"
set theNote to item 1 of (get selection)
set theTitle to (title of theNote)
end tell
Run Code Online (Sandbox Code Playgroud)
Applescript 的意思很好,但它隐藏了很多实现细节,这使得一些错误看起来比它们更随机。“隐含的 get 命令”的陷阱已经被很好地涵盖了,所以我将用一个引述来总结一下。
可能导致问题的一件事是命令“get”。通常,当您运行“我的名字”之类的命令时,命令 get 是隐含的,因此您实际上是在运行“获取我的名字”。问题是隐含的“get”并不总是如此。所以有时你必须明确地说“get”。每当我遇到像您这样的问题时,我尝试的第一件事就是在命令中添加“get”...
| 归档时间: |
|
| 查看次数: |
742 次 |
| 最近记录: |