AppleScript"无法获得所有帐号#34;

时间:2017-01-04 17:55:24

标签: automation applescript ui-automation

我今天第一次尝试使用AppleScript。

想要记录我的Notes.app

中每个音符的名称

这是我的剧本:

tell application "Notes"
    activate
    set mainAccount to the name of account 1
    tell account mainAccount
        repeat with n in notes
            log name of n as string
        end repeat
    end tell
end tell

我收到错误消息:

tell application "Notes"
    activate
    get name of account 1
        --> "iCloud"
    exists folder "Archive" of account "iCloud"
        --> true
    count every note of account "iCloud"
        --> error number -1728 from every note of account "iCloud"
Result:
error "Notes got an error: Can’t get every note of account \"iCloud\"." number -1728 from every note of account "iCloud"

这里发生了什么?

1 个答案:

答案 0 :(得分:0)

帐户没有备注,只有文件夹。

因此脚本可以这样写:

tell application "Notes"
    activate
    set mainAccount to the name of account 1
    tell account mainAccount
        repeat with f in folders
            repeat with n in notes of f
                log name of n as string
            end repeat
        end repeat
    end tell
end tell