Sunday, October 13, 2019

#1 2019-01-06 12:07:21 pm

Eurobubba
Member
Registered: 2010-09-06
Posts: 4

Get link to Notes.app note in script?

There's a rather clumsy process for getting a URL link to a Notes.app note via the collaboration button. I'm wondering whether there's a way to programmatically access that link in AppleScript. The dictionary shows that notes have an id property, but at least at first glance there doesn't seem to be any connection between that id and the URL (unlike the case in Mail, for example). Does anyone know how to get the link without a lot of manual fiddling?

Offline

 

#2 2019-07-03 01:51:15 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 614

Re: Get link to Notes.app note in script?

There is a simpler process (than described on the sites so far) to get a link to a Notes.app's note placed in one of the folders on iCloud, without real sharing:

1) Open Notes.app
2) Select one of the notes of iCloud account
3) Press collaboration button
4) On pop up window select iMessages
5) Press button "Share"

Popups window with link, which you can copy.

NOTE: No need to enter email address or to make real shared note. Only copy the link, then press "CANCEL"

All steps can be scripted BUT will involve UI Scripting with "System Events". Steps 2) and 4) require third-party mouse tools too.

Last edited by KniazidisR (2019-07-03 02:06:47 pm)


macOS Mojave -- version 10.14.4
Safari -- version 12.1

Offline

 

#3 2019-07-06 05:27:39 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 614

Re: Get link to Notes.app note in script?

Here I wrote a script that uses 2 assumptions:

1) You have the "Notes" application open and a note selected from the "iCloud" account.
2) You have installed the utility "MouseTools".

Here is the script, which would be better to convert into Quick Action (that is, custom Service), and which will open by right-clicking on the selected iCloud's note:

Applescript:


set mouseToolsPath to "'Applications/MouseTools'"

tell application "Notes" to tell window 1
   activate
   set zoomed to true -- ENTER ZOOMED SCREEN MODE
end tell

tell application "System Events" to tell application process "Notes"
   click UI element 10 of toolbar 1 of window "Notes" -- CLICK COLLABORATION BUTTON
   
   -- WHAIT UNTIL WINDOW "Add People" BECOMES ACTIVE
   repeat until exists window "Add People"
       delay 0.1
   end repeat
   
   do shell script mouseToolsPath & " -x 558 -y 388 -leftClick" -- SELECT "MESSAGES"
   click UI element "Share" of window "Add People" -- CLICK "SHARE" BUTTON
   
   -- WHAIT UNTIL WINDOW "Messages" BECOMES ACTIVE
   repeat until exists window "Messages"
       delay 0.1
   end repeat
   
   tell text field "To:" of scroll area 1 of window "Messages"
       keystroke return -- GO FOCUS TO THE LINK SCROLL AREA
   end tell
   
   -- COPY LINK SCROLL AREA CONTENTS TO THE CLIPBOARD
   click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
   click menu item "Copy" of menu 1 of menu bar item "Edit" of menu bar 1
   
   -- CLOSE WINDOW "Messages", NO NEED REAL SHARING
   click UI element "Cancel" of window "Messages"
end tell

-- GET THE URL
set myURL to paragraph 2 of (the clipboard as text)

Last edited by KniazidisR (2019-07-07 11:59:18 am)


macOS Mojave -- version 10.14.4
Safari -- version 12.1

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)