On Sidenotes:
If menu items exist they’re certainly hidden (when it’s focused it doesn’t present a menu).
I managed to have success with these scripts:
Get Name
use AppleScript version "2.4"
use scripting additions
on run
-- Back-up of clipboard contents:
set strExistingClip to the clipboard
tell application "SideNotes"
activate
delay 0.1
end tell
tell application "System Events"
keystroke "a" using {command down}
keystroke "c" using {command down}
delay 0.1
key code 124
end tell
set strClip to (the clipboard as «class utf8»)
tell application "SideNotes"
script go
on |λ|(fldr)
tell fldr to notes where its text = strClip
end |λ|
end script
set xs to my concatMap(go, its folders)
end tell
set the clipboard to strExistingClip
if {} ≠ xs then
tell application "SideNotes"
set refNote to item 1 of xs
set idNote to id of refNote
set idFolder to id of first folder where id of its notes contains idNote
end tell
set strName to take(1, paragraphs of ((text of refNote) as string))
strName
else
""
end if
end run
-- concatMap :: (a -> [b]) -> [a] -> [b]
on concatMap(f, xs)
set lng to length of xs
set acc to {}
tell mReturn(f)
repeat with i from 1 to lng
set acc to acc & (|λ|(item i of xs, i, xs))
end repeat
end tell
return acc
end concatMap
-- mReturn :: First-class m => (a -> b) -> m (a -> b)
on mReturn(f)
-- 2nd class handler function lifted into 1st class script wrapper.
if script is class of f then
f
else
script
property |λ| : f
end script
end if
end mReturn
-- min :: Ord a => a -> a -> a
on min(x, y)
if y < x then
y
else
x
end if
end min
-- take :: Int -> [a] -> [a]
-- take :: Int -> String -> String
on take(n, xs)
if 0 < n then
items 1 thru min(n, length of xs) of xs
else
{}
end if
end take
-- unwords :: [String] -> String
on unwords(xs)
set {dlm, my text item delimiters} to ¬
{my text item delimiters, space}
set s to xs as text
set my text item delimiters to dlm
return s
end unword
Get Address
use AppleScript version "2.4"
use scripting additions
on run
-- Back-up of clipboard contents:
set strExistingClip to the clipboard
tell application "SideNotes"
activate
delay 0.1
end tell
tell application "System Events"
keystroke "a" using {command down}
keystroke "c" using {command down}
delay 0.1
key code 124
end tell
set strClip to (the clipboard as «class utf8»)
tell application "SideNotes"
script go
on |λ|(fldr)
tell fldr to notes where its text = strClip
end |λ|
end script
set xs to my concatMap(go, its folders)
end tell
set the clipboard to strExistingClip
if {} ≠ xs then
tell application "SideNotes"
set refNote to item 1 of xs
set idNote to id of refNote
set idFolder to id of first folder where id of its notes contains idNote
end tell
set strName to unwords(take(7, words of ((text of refNote) as string)))
"hook://sidenotes/" & idFolder & "|" & idNote
else
""
end if
end run
-- concatMap :: (a -> [b]) -> [a] -> [b]
on concatMap(f, xs)
set lng to length of xs
set acc to {}
tell mReturn(f)
repeat with i from 1 to lng
set acc to acc & (|λ|(item i of xs, i, xs))
end repeat
end tell
return acc
end concatMap
-- mReturn :: First-class m => (a -> b) -> m (a -> b)
on mReturn(f)
-- 2nd class handler function lifted into 1st class script wrapper.
if script is class of f then
f
else
script
property |λ| : f
end script
end if
end mReturn
-- min :: Ord a => a -> a -> a
on min(x, y)
if y < x then
y
else
x
end if
end min
-- take :: Int -> [a] -> [a]
-- take :: Int -> String -> String
on take(n, xs)
if 0 < n then
items 1 thru min(n, length of xs) of xs
else
{}
end if
end take
-- unwords :: [String] -> String
on unwords(xs)
set {dlm, my text item delimiters} to ¬
{my text item delimiters, space}
set s to xs as text
set my text item delimiters to dlm
return s
end unword
I wasn’t sure how to pull off the special code blocks above. 
I haven’t yet had any luck with Open Item, but all I really did to your script was turn the markdown-formatted return value into just the URL (for Get Address) and just the name (for Get Name).
I’m not sure if there’s a way of returning markdown links, but Hook seemed to be unhappy with it and it started working after that change.
I do see two flashes of text selection when I run the script (one for each script) — I’ve reached out to the author of Hook about providing more AppleScript support.
Thanks again for your help in getting to this point!
On IntelliJ IDEA:
I validated that the script is indeed firing by writing to a file as a debug output (perhaps I’m naïve to the options available, but that was what I used as my console.log
equivalent).
It looks like it’s finding an application named idea
but that that application’s windows.length
is 0
and at that point we can’t continue forward.