Interact with the Notes app on macOS
carbon | cocoa | win32 | win64 |
---|---|---|---|
before-mojave branch uses 10.13 SDK
This version uses AEDeterminePermissionToAutomateTarget
from the 10.14 SDK
c.f. https://www.felix-schwarz.org/blog/2018/08/new-apple-event-apis-in-macos-mojave
This tool may help sign your application
If access has been previously denied by user, the application will not ask again.
The use must manually enable it.
Alternatively, you can clear all permissions for Automation.
tccutil reset AppleEvents
before
after
The main application must have the following keys in Info.plist
Key: Privacy - AppleEvents Sending Usage Description (NSAppleEventsUsageDescription
)
Value: Reason to access private data
If the entry does not exist, plugin calls will silently fail.
If the app is signed, you obviously have to sign it again after editing Info.plist
.
If the key exists, the system will ask the user for permission on the first attempt.
You will also need to codesign the built app (with the --deep
option, since some frameworks are unsigned).
To sign, you may have to xattr -rc
and first clean all files inside the app.
This plugin uses several different ways to access Notes.
The file Notes.h
was generated by sdef
.
sdef /Applications/Notes.app | sdp -fh --basename Notes
Most functions ask the Notes app to complete the task by sending obj-c
messaged over ScriptingBridge.
Adding attachments seems impossible via ScriptingBridge. So NSAppleScript is used instead.
The path of attachment files is likewise not exposed via AppleScript. So direct access to the backend SQLite database is performed.
- Example of connecting to the Notes backend SQLite database.
sqlite3 /Users/miyako/Library/Group\ Containers/group.com.apple.notes/NoteStore.sqlite
note:=Notes Create note (folder;title;body;attachments{;$names})
Parameter | Type | Description |
---|---|---|
folder | TEXT | |
title | TEXT | |
body | TEXT | |
attachments | ARRAY PICTURE | or ARRAY BLOB |
names | ARRAY TEXT | |
note | OBJECT |
Properties of note
:
id
:string
name
:string
body
:string
creationDate
:string
creationLocalDate
:string
modificationDate
:string
modificationLocalDate
:string
Notes GET FOLDERS (folders)
Parameter | Type | Description |
---|---|---|
folders | COLLECTION |
Properties of folders
:
folders
:array
offolder
Properties of folder
:
id
:string
name
:string
notes
:array
ofstring
(id)folders
:array
offolder
(non-recursive)
Notes GET NOTES (notes)
Parameter | Type | Description |
---|---|---|
notes | COLLECTION |
Properties of notes
:
notes
:array
ofnote
Properties of note
:
id
:string
name
:string
attachments
:array
ofstring
(id)
Notes GET ATTACHMENTS (attachments)
Parameter | Type | Description |
---|---|---|
attachments | COLLECTION |
Properties of attachments
:
attachments
:array
ofattachment
Properties of attachment
:
id
:string
name
:string
note
:string
(id)
Notes GET ACCOUNTS (accounts)
Parameter | Type | Description |
---|---|---|
accounts | COLLECTION |
Properties of accounts
:
accounts
:array
ofaccount
Properties of account
:
id
:string
name
:string
folders
:array
offolder
(non-recursive)
folder:=Notes Create folder (parent;name)
Parameter | Type | Description |
---|---|---|
parent | TEXT | |
name | TEXT | |
folder | OBJECT |
Properties of folder
:
id
:string
name
:string
path:=Notes Get attachment (id)
Parameter | Type | Description |
---|---|---|
attachment | TEXT | |
path | TEXT |
Note: This methods call sqlite3
to resolve the attachment path.
note:=Notes Get note (id)
Parameter | Type | Description |
---|---|---|
id | TEXT | |
note | OBJECT |
Properties of note
:
id
:string
name
:string
body
:string
folder
:string
(id)creationDate
:string
creationLocalDate
:string
modificationDate
:string
modificationLocalDate
:string
attachments
:array
ofstring
(id)
folder:=Notes Get folder (id)
Parameter | Type | Description |
---|---|---|
id | TEXT | |
folder | OBJECT |
Properties of folder
:
id
:string
name
:string
folders
:array
offolder
(recursive)notes
:array
ofnote
(top level only)
Properties of note
:
id
:string
name
:string
account:=Notes Get account (id)
Parameter | Type | Description |
---|---|---|
id | TEXT | |
account | OBJECT |
Properties of account
:
id
:string
name
:string
folders
:array
offolder
(recursive)
Notes SET NOTIFICATION (method)
Parameter | Type | Description |
---|---|---|
method | TEXT |
method:=Notes Get notification
Parameter | Type | Description |
---|---|---|
method | TEXT |
The following methods are not implemented (does nothing) in this version
Notes SET NOTIFICATION (method)
method:=Notes Get notification