Skip to content

Instantly share code, notes, and snippets.

@tekacs
Created November 13, 2019 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekacs/996f0c22b58f36bbec61c8214e984ae9 to your computer and use it in GitHub Desktop.
Save tekacs/996f0c22b58f36bbec61c8214e984ae9 to your computer and use it in GitHub Desktop.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
-- Back up clipboard contents:
set savedClipboard to the clipboard
tell application "SideNotes"
activate
delay 0.25
tell application "System Events" to keystroke "a" using {command down}
tell application "System Events" to keystroke "c" using {command down}
tell application "System Events" to key code 124
end tell
set theSelectedText to the clipboard
set AppleScript's text item delimiters to {ASCII character 13} -- take \r
set tstList to text items of theSelectedText
set AppleScript's text item delimiters to {ASCII character 10} -- and turn it into \n
set theSelectedText to (tstList as text)
-- Restore clipboard:
set the clipboard to savedClipboard
tell application "SideNotes"
repeat with f in folders
repeat with n in (get note in f)
set t to text of n
if t is equal to theSelectedText then
return "hook://sidenotes/" & (id of f) & "/" & (id of n)
end if
end repeat
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment