以编程方式访问苹果笔记内容

9

是否有可能以编程方式访问苹果笔记(即macOS和iOS中预装的应用程序)的内容?

1个回答

14

macOS可以使用AppleScript进行脚本编写。

要记录所有笔记,请打开“Script Editor”并创建一个新脚本,然后按以下步骤操作:

点击运行按钮。

tell application "Notes"
  repeat with theNote in notes
    set theNoteName to name of theNote
    log theNoteName

    set theNoteBody to body of theNote
    log theNoteBody

    log "----"
  end repeat
end tell

或者,创建一个文本文件,内容如上所示,并将其保存为notes.scpt,然后从终端运行:

osascript notes.scpt

1
有没有用JS实现这个的方法?我无法让它工作 :/ `var notes = Application("notes");var counter = 0;console.log(notes.notes.length);while (counter < 10) { for (i = 0; i < notes.notes.length; i++) { note = notes[i]; console.log(note["name"]); console.log(note["body"]); counter = counter + 1;}}` - ovatsug25
它确实打印出了我拥有的笔记数量,但它没有打印出属性的值 - 似乎找不到方法来做到这一点。 - ovatsug25
1
看起来JS API是这样的:var app = Application("Notes"); app.notes().forEach(note => { console.log(note.name()); });向https://github.com/abruneau/apple-notes-jxa/blob/master/lib/note.js致敬,感谢他们提供的解决方案。 - Aleksei

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接