I appear to have Zotero working with Hook, with the caveat that you need to install the ‘zotxt’ plugin for Zotero. The GetAddress script queries the inbuilt webserver of Zotero via the API that zotxt exposes twice to get the key of the selected item and then the title of the selected item, and then forms a markdown link for them.
It works for me, but I was hoping that someone who actually knows AppleScript could provide comments (especially the kludge to get the title field from the response). Also it would be useful for other Zotero users to test.
set zotext_result to do shell script "curl -s -d selected=t\\&format=key -G http://127.0.0.1:23119/zotxt/items"
set AppleScript's text item delimiters to quote
set theTextItems to every text item of zotext_result
set link to "zotero://select/items/" & item 2 of theTextItems
set zotext_result to do shell script "curl -s -d selected=t\\&format=json -G http://127.0.0.1:23119/zotxt/items"
set AppleScript's text item delimiters to "\"title\""
set newText to text items of zotext_result
set AppleScript's text item delimiters to "\""
set newText2 to text items of item 2 of newText
set theName to item 2 of newText2
set theLink to "[" & theName & "](" & link & ")"
return theLink
Thanks for that, @brock ! And Welcome to the Hook Productivity Forum , @harets ! Great to see integration with Zotero. I used it a long time ago before switching to Papers. But Papers2020 lacks automation, so I personally am switching to Bookends. Hook working with zotero is very helpful to many. We will look at the AppleScript in more detail. On Linkable Mac Apps – Hook, I’ve added a link to this topic .
We’ve made some changes to the proposed Zotero script. We’d love to get some feedback from you or another Zotero user regarding the changes. To quote our dev who did the work:
Convert JSON string to JSON object using AppleScriptObj-C, so we can correctly retrieve the title value. If We use delimiter quote to break text apart to get title value, it will have problem if title itself contains a quote.
Get item ID and item title from the same entity of JSON response. This will make sure the ID and title are from the same item when there are multiple selections, though it rarely happens.
Change URL zotero://select/items/id to zotero://select/library/items/id. For URL zotero://select/items/id, opening it only opens Zotero window, it does not select the right entry. URLs of the form zotero://select/library/items/id seem to work fine. That’s what happens on my Mac. I would like to see the user’s feedback. They are more familiar with Zotero.
Here’s her revision:
use scripting additions
use framework "Foundation"
set zotext_result to do shell script "curl -s -d selected=t\\&format=json -G http://127.0.0.1:23119/zotxt/items"
set str to current application's NSString's stringWithString:zotext_result
set theData to str's dataUsingEncoding:(current application's NSUTF8StringEncoding)
set {res, theErr} to current application's NSJSONSerialization's JSONObjectWithData:theData options:0 |error|:(reference)
if res is missing value then error (theErr's localizedDescription() as text) number -10000
set aList to res as list
set theName to |title| of item 1 of aList
set theId to |id| of item 1 of aList
set AppleScript's text item delimiters to "/items/"
set theTextItems to every text item of theId
set theLink to item 2 of theTextItems
set theLink to "[" & theName & "](zotero://select/library/items/" & theLink & ")"
return theLink
Thank you!
( 2020-07-23 @ 09:17 I fixed two typos in the description, not the script. Discourse forum software can do a ‘diff’.)
Seems to work OK for me too, presuming that pasting the updated script into the window in Hook is sufficient to update what Hook is actually running. Clicking a pasted link selects the correct item and opens Zotero first if it isn’t running.
I now need to sit and look at the changes in detail so I learn some more AppleScript - my version was just pasted from various scripts and hacked at until it worked
Hi @LucB, I have just updated Hook Using Hook’s Check for App Updates and Update Scripts function and when I trigger Hook it says there is no linkable item in Zotero.
The zotero scripts built into the app are the ones we’ve provided. Please make sure they are not overridden ( a * would show up if they were). It’s early days for Zotero integration – not having received much feedback about it.
I had this issue yesterday, but noticed that it was because I had an attached PDF selected in Zotero rather than the reference that the attachment was attached to. When I selected the reference, Hook worked as expected.
I checked and the scripts are not overridden - there was no a *, just the Hook logo with the text ‘no linkable item in Zotero’ below.
I tried linking to references in Zotero with or without a pdf and was told ‘no linkable item in Zotero’. I also tried linking to a pdf in Zotero, rather than the actual reference, and that did not work either.
Hi LucB, I have grant accessibility permission to Hook but I don’t get the options you do within Hook. In fact, I don’t have the ‘automation’ menu. Please see below.
Yesterday, I was working on my work computer. Not sure what version of macOS is on that machine. I will check next week. But the same issue is occurring on my home Mac, which is using macOS High Sierra (10.13.6).
I have a regular account on my home Mac. Not sure about the work computer. I don’t normally hit any permission access issues.
Both Word and OneNote are the latest versions so what could be causing the ‘no linkable item’ issue for Word, OneNote and Zotero? When I go to ‘About’ in Hook I can see that my Essentials licence is recorded so its not a licence issue.
I wonder whether I am using Hook correctly? I can link to a Word document in Finder but when the same document is open (and Word is the top screen and no other palette is open) Hook says there is ‘no linkable item’. Is this right?
I save all my files locally but they are synced with OneDrive. Could this be causing the issue? I have made sure that any Word doc has finished saving when attempting to Hook with it.