Trying to Write New BookEnds Script

The current Hook BookEnds script can only create a link to a Citation. However Bookends is able to create a link to a Group as well.

The same menu item copies a link to the clipboard for either a citation or a group - it is Edit / Copy Hypertext Link / Copy as Link

image

This is some help from UI browser to identify the name of that menu item:

image

Based on that I tweaked some other scripts and attempted this as a new Get Address script for BookEnds:

image

Unfortunately the script hangs up when I try to use it in Hook. When I try it on its own I get this error:

Execute an AppleScript failed with script error: text-script:116:239: execution error: System Events got an error: Can’t get process “com.sonnysoftware.bookends”. (-1728). Macro “Get Bookends Link” cancelled (while executing Execute AppleScript)

Any thoughts on what I am doing wrong?

@LucB

This version is very close to working to with both citations and Groups. It returns the proper value when I run it outside of Hook. But when run in Hook it says “No linkable item found.” Thoughts?

tell application “System Events”
tell process “Bookends”
set the clipboard to “”
delay 0.3
click menu item “Copy As Link” of menu 1 of menu item “Copy Hypertext Link” of menu 1 of menu bar item “Edit” of menu bar 1
delay 0.3
set myURL to the clipboard
end tell
end tell

Thanks for giving that a try, @rkaplan. We’re unlikely to add UI scripting calls to integrate with an app that has AppleScript support. I think our best bet is for one of us to ask on the Bookends forum - Sonny Software. The dev, Jon Ashwell, has invited us to ask questions pertinent to Hook + Bookends there. (if there’s an additional API required, perhaps the dev would be willing to add it.)

1 Like