问题描述
我想获取当前正在查看的 Apple Note(使用 Mac 上的“notes”应用程序)的 id(或名称)(不是浮动的,只是“选定的”note),使用 Applescript或JXA。这可能吗?
我知道如何使用 Applescript 获取最近保存的笔记的 ID:
tell application "Notes"
get id of note 0 //side note: I think saying "note 1" also gives same result--not sure of difference
end tell
但是当您正在查看笔记(因此笔记在前台窗口中)但它不是最后保存的笔记时呢?有没有办法得到那个笔记的id?
解决方法
我还发现以下内容适用于 macOS 11+。我根据此 macscripter.net 讨论得到了答案,这表明它可以从 macOS 10.15 开始运行,但我目前无法在 macOS 11 之前进行验证:
tell application "Notes"
set noteID to «class seld» of (selection as record)
set noteContainerID to «class seld» of ((container of note id noteID) as record)
set selectedNoteName to name of note id noteID
get selectedNoteName
end tell