Skip to content

miyako/4d-plugin-notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

version platform license downloads

4d-plugin-notes

Interact with the Notes app on macOS

See 4d-utility-sign-app on how to enable the plugin in 4D.

Documentation

Bug: It is no longer possible to add an attachment in macOS Catalina.

see:

https://hookproductivity.com/help2/integration/hook-and-macos-10-15-catalina-notes-app/ https://forum.latenightsw.com/t/notes-app-scripting-dictionary-defective-on-catalina/2136

tell application "Notes"
  note id "x-coredata://2BB27C30-9D8D-4501-8ADD-D16531CA22F5/ICNote/p51"
  (*
  returns:
  show id "x-coredata://2BB27C30-9D8D-4501-8ADD-D16531CA22F5/ICNote/p51" of application "Notes"
  it is not possible to use this as a specifier; bummer! (error 1700)
  *)
  
end tell

Important

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

4d-utility-build-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

2019-03-05 16 01 49

after

2019-03-05 16 02 40

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.

2019-03-05 16 06 08

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.

2019-03-05 16 09 11

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.

Architecture

This plugin uses several different ways to access Notes.

ScriptingBridge

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.

NSAppleScript

Adding attachments seems impossible via ScriptingBridge. So NSAppleScript is used instead.

SQLite

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